Home » C programs » C 'goto' programs

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



In this program, we are going to learn how to print ASCII values of all digits using goto statement?
Submitted by Manju Tomar, on November 19, 2017

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.

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?





Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.



Comments and Discussions


We are using Google to publish ads on our website; Google has its own privacy policies. They may save log, cookies on your system. Google may also collect information of your system like IP address, region, city, country. For more details please go through the Google’s privacy policy.