In this article, we will discuss the concept of C++ Program for print all Alphabets between given range using loops
In this post, we are going to learn how to display all the upper case(A to Z) and lower case (a to z) Alphabets between given range using loops on C++ programming language
The program displays all the upper case and lower case alphabet letters between given range using for loop in C++ language
Program 1
#include <iostream> #include <conio.h> using namespace std; int main() { char i,ch1,ch2; cout<<"Enter the two Alphabet of the range: "<<endl;; cin>>ch1>>ch2; for(i=ch1; i<=ch2; i++){ cout<<" "<<i; //display uppercase or lower case Alphabets with space } getch(); return 0; }
When the above code is executed, it produces the following result
Case 1
Enter the two Alphabet: j t Alphabet letters between j and t: j k l m n o p q r s t
Case 2
Enter the two Alphabet: C K Alphabet letters between C and K: C D E F G H I J K
In the above program, we are using a for loop, this is used to print upper case Alphabet letters or lower case Alphabet letters between the given range
Approach
The program displays all the upper case and lower case alphabet letters between given range using while loop in C++ language
Program 2
#include <iostream> #include <conio.h> using namespace std; int main() { char i,ch1,ch2; cout<<"Enter the two Alphabet: "<<endl; cin>>ch1>>ch2; cout<<"Alphabet letters between "<<ch1<<" and "<<ch2<<": "<<endl;; i=ch1; while(i<=ch2){ cout<<" "<<i; i++; //display uppercase and lower case Alphabets with space } getch(); return 0; }
When the above code is executed, it produces the following result
Case 1
Enter the two Alphabet: l t Alphabet letters between l and s: l m n o p q r s t
Case 2
Enter the two Alphabet: D K Alphabet letters between D and K: D E F G H I J K
In the above program, we are using a while loop, this is used to print upper case Alphabet letters or lower case Alphabet letters
Approach
The program displays all the upper case and lower case alphabet letters between given range using do-while loop in C++ language
Program 3
#include <iostream> #include <conio.h> using namespace std; int main() { char i,ch1,ch2; cout<<"Enter the two Alphabet: "<<endl; cin>>ch1>>ch2; cout<<"Alphabet letters between "<<ch1<<" and "<<ch2<<": "<<endl;; i=ch1; do{ cout<<" "<<i; i++; //display uppercase and lower case Alphabets with space } while(i<=ch2); getch(); return 0; }
When the above code is executed, it produces the following result
Case 1
Enter the two Alphabet: m t Alphabet letters between m and t: m n o p q r s t
Case 2
Enter the two Alphabet: E M Alphabet letters between E and M: E F G H I J K L M
In the above program, we are using a do-while loop, this is used to print upper case Alphabet letters or lower case Alphabet letters
Approach
Suggested for you
Similar post
Java program to print all upper case and lower case Alphabets
C++ program to print all upper case and lower case Alphabets
C program to print all upper case and lower case Alphabets
Java code to print all upper case and lower case Alphabets between the given range
C++ code to print all upper case and lower case Alphabets between the given range
C code to print all upper case and lower case Alphabets between the given range
PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…
PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…
5 methods to add two numbers in Java In this tutorial, we will discuss the…
Python full Pyramid star pattern program In this tutorial, we will discuss the concept of…
Write a function or method to convert C into F -Entered by the user In…
How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…