Display Characters From A To Z Using Loop In C Programming

In this example, you will learn to print all the letters of the English alphabet.

C Program to Display Alphabet In Uppercase

	
#include <stdio.h>
int main() {
    char c;
    for (c = 'A'; c <= 'Z'; ++c)
        printf("%c ", c);
    return 0;
}
	

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 Alphabet In Lowercase

	
#include <stdio.h>
int main() {
    char c;
    for (c = 'a'; c <= 'z'; ++c)
        printf("%c ", c);
    return 0;
}
	

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 Alphabet in Uppercase or Lowercase

	
#include <stdio.h>
int main() {
    char c;
    printf("Enter U to display uppercase alphabets.\n");
    printf("Enter L to display lowercase alphabets. \n");
    printf("Enter Your Choice :: ");
    scanf("%c", &c);

    if (c == 'U' || c == 'u') {
        for (c = 'A'; c <= 'Z'; ++c)
            printf("%c ", c);
    } else if (c == 'L' || c == 'l') {
        for (c = 'a'; c <= 'z'; ++c)
            printf("%c ", c);
    } else {
        printf("Error! You entered an invalid character.");
    }

    return 0;
}
	

Output :

	
Enter U to display uppercase alphabets.
Enter L to display lowercase alphabets. 
Enter Your Choice :: U
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 
	

Share your thoughts

Ask anything about this examples