In this program, you will learn how to use the C++ programming language to print the alphabet from a to z in lowercase. We can use a while loop and for loop to accomplish this goal.
More like this
- Create class methods using C++
- Reference Variables in C++ Explained
- Check if a date is valid or not using C++
C++ program to print all alphabets using a for loop
Below is the program to print all alphabets in C++ using the ‘for’ loop. It loops through all alphabets from a to z, then prints the variable alphabet to the console.
#include<iostream> using namespace std; int main() { cout << "\n---Program to print all alphabets---\n"; for(char alphabets = 'a'; alphabets <= 'z'; alphabets++) { cout << alphabets << " "; } return 0; }
Result
---Program to print all alphabets--- 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
C++ program to print all alphabets using while loop
Another way to print all alphabets in C++ is to use a while loop method:
#include<iostream> using namespace std; int main() { cout << "\n---Program to print all alphabets---\n"; char alphabets='a'; while(alphabets <= 'z') { cout << alphabets << " "; alphabets++; } return 0; }
Result
---Program to print all alphabets--- 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
Happy coding!

IT specialist Veteran