In this program, we are going to see how we can print alphabets in C++. The program is pretty simple and straight forward. Here ASCII value of the characters comes into the picture, we use the ASCII value of starting and end character to run the loop.

See also: Find ASCII value of a character

Logic

ASCII value of small letter “a” is 97 and for “z” it is 122, so we run the loop from 97 to 122 and then inside the loop we have to print the current character.

Program

#include <iostream>

using namespace std;

int main() {

    char c;

    cout << "Alphabets from a - z are : " << endl;

    // Start from ASCII value of small letter a.
    for(c = 'a'; c <= 'z'; c++) {

        cout << c << " ";

    }

    return 0;
}

Output

Alphabets from a - z are:
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