🔀Beginner

Print Alphabets From A to Z Using Loop

Display all alphabets

This program prints all alphabets from A to Z using a loop. In C, characters are internally stored as ASCII values, so we can loop through them numerically.

📊 ASCII Values

'A' = 65
'Z' = 90
'a' = 97
'z' = 122

C Program to Print A to Z

alphabets_a_to_z.c
C
1#include <stdio.h>
2
3int main() {
4 char ch;
5
6 printf("Uppercase Letters:\n");
7 for (ch = 'A'; ch <= 'Z'; ch++) {
8 printf("%c ", ch);
9 }
10
11 printf("\n\nLowercase Letters:\n");
12 for (ch = 'a'; ch <= 'z'; ch++) {
13 printf("%c ", ch);
14 }
15
16 printf("\n");
17 return 0;
18}
Output

Uppercase Letters:

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

 

Lowercase Letters:

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

📖 Code Explanation

CodeExplanation
char ch;Declare a character variable
ch = 'A'Initialize with character 'A' (ASCII 65)
ch <= 'Z'Loop until 'Z' (ASCII 90)
ch++Increment to next ASCII character

🎯 Key Takeaways

Characters can be used in for loops
'A' to 'Z' are consecutive ASCII values
%c format specifier for characters
ch++ increments to next character