Home »
C programs »
C 'goto' programs
C program to print ASCII values of all uppercase alphabets using goto statement
In this program, we are going to learn how to print ASCII values of all uppercase alphabets using goto statement?
Submitted by Manju Tomar, on November 19, 2017
Problem statement
We have to print ASCII values of all uppercase alphabets along with alphabets using C program.
Problem solution
In this program, we are using a variable named count which will be initialized by 'A' and with the help of label, goto statement and condition; we are printing the ASCII values of all uppercase alphabets.
C program to print ASCII values of all uppercase alphabets
#include<stdio.h>
int main()
{
//counter, it can also be declared as 'char'
int count;
//initializing counter by 'A'
count= 'A';
//definig label
start:
printf("%c [%d] ",count,count);
count++;
//jumping back to 'stat' if condition is true
if(count <= 'Z')
goto start;
return 0;
}
Output
A [65] B [66] C [67] D [68] E [69] F [70] G [71] H [72]
I [73] J [74] K [75] L [76] M [77] N [78] O [79] P [80]
Q [81] R [82] S [83] T [84] U [85] V [86] W [87] X [88]
Y [89] Z [90]
This is a way, by which we can print ASCII values of all uppercase characters (alphabets), please write through comment, if you have any doubt?
C Goto Programs »