C++ program to print all upper case and lower case Alphabets
C++ program to print all upper case and lower case Alphabets
In this article, we will discuss the concept ofC++ program to print all upper case and lower case Alphabets
In this post, we are going to learn how to display all the upper case and lower case Alphabets using loops c++ language
display lower case and upper case
C++ program to print all the Alphabets using for loop
The program displays all the upper case and lower case alphabet letters from a to z using for loop in C++ language
Program 1
#include
#include
using namespace std;
int main()
{
char ch;//char variable declaration
//Printing upper case Alphabets
cout<<"Uppercase Alphabets are: \n";
for(ch='A'; ch<='Z'; ch++){
cout<
When the above code is executed, it produces the following result
Output 1
In the above program, we are using two for loops, one is used to print upper case letters and another to print lower case alphabet letters
C++ code to display all the Alphabets using while loop
The program displays all the upper case and lower case alphabet letters from a to z using while loop in C++ language
Program 2
#include
#include
using namespace std;
int main()
{
char ch;//char variable declaration
//Printing upper case Alphabets
cout<<"Uppercase Alphabets are: \n";
ch='A';
while( ch<='Z'){
cout<
When the above code is executed, it produces the following result
Output 2
In the above program, we are using two while loops, one is used to print upper case letters and another to print lower case letters
C++ code to display all the Alphabets using do-while loop
The program displays all the upper case and lower case alphabets letters from a to z using do-while loop in C++ language
Program 3
#include
#include
using namespace std;
int main()
{
char ch;//char variable declaration
//Printing upper case Alphabets
cout<<"Uppercase Alphabets are: \n";
ch='A';
do{
cout<
When the above code is executed, it produces the following result
Output 3
In the above program, we are using two do-while loops, one is used to print upper case letters and another to print lower case letters
Approach
We will declare a counter variable “ch” in loops (for loop, while loop and do-while loop) and initialize it by “a”(for print lower case) or “A” (for print upper case);
The program checks the given condition(ch<=”z” (lower case) or ch<=”Z“(Upper case), if the condition is true, alphabets will be printed
if the condition is false – loops will be terminated