Q:

C program to print ASCII values of all digits using goto statement

0

C program to print ASCII values of all digits using goto statement

We have to print ASCII values of all digits along with digits (in character) using C program.

In this program, we are using a variable named count which will be initialized by '0' and with the help of label, goto statement and condition; we are printing the ASCII values of all digits.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program

#include<stdio.h>

int main()
{
	//counter, it can also be declared as 'char'
	int count;
	//initializing counter by 'a'
	count= '0';
	//definig label
	start:
	printf("%c [%d] ",count,count);
	count++;
	//jumping back to 'stat' if condition is true
	if(count <= '9')
		goto start;
	return 0;
}

Output

0 [48] 1 [49] 2 [50] 3 [51] 4 [52] 5 [53] 6 [54] 7 [55] 8 [56] 9 [57] 

This is a way, by which we can print ASCII values of all digits, please write through comment, if you have any doubt?

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now