English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Comprehensive Collection of C Programming Examples
In this example, you will learn to print all the letters of the English alphabet.
To understand this example, you should be familiar with the followingC Programming LanguageTopic:
#include <stdio.h> int main() { char c; for (c = 'A'; c <= 'Z'; ++c) printf("%c ", c); return 0; }
Output Result
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
In this program, the for loop is used to display English letters in uppercase.
These are some modifications to the above program. The program displays English letters in uppercase or lowercase based on the user's input.
#include <stdio.h> int main() { char c; printf("Enter u to display uppercase letters.\n"); printf("Enter l to display lowercase letters. \n"); scanf("%c", &c); if (c == 'U' || c == 'u') { for (c = 'A'; c <= 'Z'; ++c) printf("%c ", c); } for (c = 'a'; c <= 'z'; ++c) printf("%c ", c); } printf("Error! You entered an invalid character."); } return 0; }
Output Result
Enter u to display uppercase letters. Enter l to display 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