Print alphabets a to z in cpp

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.

Algorithm:

  1. Start
  2. Write the main method.
  3. Declare character variable to store first alphabet letter.
  4. Use for loop for iteration starting from a and iterate till the end.
  5. Print alphabet
  6. If loop encounter ends then stop.
  7. End.

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

123456789101112131415#include <iostream>using namespace std;int main(){char c;for(char c=’a’;c<=’z’;c++){cout<<c;}return 0;}

Output 

Cpp program to print alphabets from a to z
Cpp program to print alphabets from a to z

Explanation:

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.

5. End.