Write a program using loop statement that can print all small and capital letters in reverse order.
Answers
Explanation:
#include <stdio.h>
int main() {
char c;
for (c = 'A'; c <= 'Z'; ++c)
print ("%c ", c);
return 0;
}
In this program, the for loop is used to display the English alphabet in uppercase.
Here's a little modification of the above program. The program displays the English alphabet in either uppercase or lowercase depending upon the input given by the user.
#include <stdio.h>
int main() {
char c;
printf("Enter u to display uppercase alphabets.\n");
printf("Enter l to display lowercase alphabets. \n");
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(" rror! You entered an invalid character.");
}
return 0;
}
output
Enter u to display uppercase alphabets.
Enter l to display lowercase alphabets. l
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