C Program to Display Alphabets

CodingTute

C Program to Print Alphabets

In this example, you will learn to display alphabets sequentially using loops and ASCII values.

You can find more about ASCII here.

C Program to Display Uppercase Alphabets

#include <stdio.h>

int main()
{
    //ASCII values of A - Z (65 - 90) 
    for(int i = 65; i < 91; i++)
        printf("%c ",i);
}

Output

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

C Program to Display Lowercase Alphabets

#include <stdio.h>

int main()
{
    //ASCII values of a - z (97 - 122) 
    for(int i = 97; i < 123; i++)
        printf("%c ",i);
}

Output

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 

Explanation

We know each character holds a unique ASCII value. For uppercase alphabets (A-Z) the ASCII value ranges between 65-90 respectively and for lowercase alphabets (a-z) the ASCII value ranges between 97-122. In our c program, we loop within the range of alphabets and print the loop variable i with format specifier %c which in terms prints the respective character.

Follow us on Facebook, YouTube, Instagram, and Twitter for more exciting content and the latest updates.