Print alphabets a to z in cpp : In this tutorial, we are going to see a program to Print alphabets a to z.
For this program you only require to know the following cpp programming concept :
Looping in cpp: for loop, while loop, do while loop
Logic to Print alphabets a to z : As we know the English alphabets Starr from a and ends with z. So using for loop we iterate from start letter a and iterate till we encounter z letter and simultaneously we print each letter.
- Write the main method.
- Declare character variable to store first alphabet letter.
- Use for loop for iteration starting from a and iterate till the end.
- Print alphabet
- If loop encounter ends then stop.
As we know logic and algorithm let’s see the program to print a to z alphabet.
Cpp program to print alphabets from a to z
using namespace std;
1. First, include the preprocessor directory in a program.
2. write a main function.
3. Declare variable
c => to store the first character
4. Next write for loop
for(char c = ‘a’ ; c <= ‘z’ ; c ++)
store first character to c => a after that loop checks condition a <= z which becomes true and enters into loop block and prints the alphabet a.
Increment the character c becomes b c= b now again it checks condition b <= z which becomes true and enters in block and prints b. This process continues till z encounters. When z encountered the condition becomes false and come out of the loop.