Example:
Output alphabets: a, b, c, d, e ...
Also check this program using for loop - C program to print all alphabets from a to z using for loop.
Required knowledge
Basic C programming, While loopProgram to print alphabets
/** * C program to print all alphabets using while loop */ #include <stdio.h> int main() { char ch = 'a'; printf("Alphabets from a - z are: \n"); while(ch<='z') { printf("%c\n", ch); ch++; } return 0; }
Note: If you want to print alphabets in uppercase you just need to replace the lower-case assignment and conditional checks statements in loop which is ch='A' and ch<='Z'.
Characters in C are internally represented as an integer value known as ASCII value.
ASCII value of a = 97
ASCII value of z = 122
Hence we can also write the above program using ASCII values.
Characters in C are internally represented as an integer value known as ASCII value.
ASCII value of a = 97
ASCII value of z = 122
Hence we can also write the above program using ASCII values.
Program to display alphabets using ASCII value
/** * C program to display all alphabets using while loop */ #include <stdio.h> int main() { int ch = 97; printf("Alphabets from a - z are: \n"); while(ch<=122) { printf("%c\n", ch); ch++; } return 0; }
Output
Alphabets from a - z are:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Happy coding ;)
You may also like
- Loop programming exercise index.
- C program to check whether a character is alphabet or not.
- C program to check whether a character is alphabet, digit or special character.
- C program to check whether a character is vowel or consonant.
- C program to print all natural numbers from 1 to n.
- C program to check whether a number is even or odd.
- C program to print all even numbers between 1 to 100.
- C program to print sum of all even numbers between 1 to n.
- C program to enter any number and print its table.
- C program to find sum of all natural numbers between 1 to n.
- C program to print ASCII values of all characters.
- C program to enter any number and print it in words.
- C program to count total number of notes in a given amount.
- C program to check whether a year is leap year or not.