English alphabet
Alphabets are the set of codes that enable written communication. English alphabets are the basic constituent of the English language. They are symbols or letters with a specific sound and are used in the formation of words in the English language. The English language contains 26 alphabets out of which 5 are vowels and 21 are consonants. The uppercase and lowercase are the two forms of the English alphabet. Commonly, uppercase letters are known as capital letters whereas lowercase letters are known as small letters.Write a program in C++ to print the uppercase and lowercase form of all English alphabets.
In this program, we assign two character variables with 'a' and 'A' as their initial value. We will use the post-increment operator(++) to generate the successive alphabets till 'z' and 'Z'. We will use a for loop to print all the alphabets.
#include<iostream.h>
#include<conio.h>
void main()
{
int n;
char capital='A',small='a';
clrscr();
for(n=1;n<=26;n++)
{
cout<<capital++<<small++<<"\t";
}
getch();
}
Program
#include<iostream.h>
#include<conio.h>
void main()
{
int n;
char capital='A',small='a';
clrscr();
for(n=1;n<=26;n++)
{
cout<<capital++<<small++<<"\t";
}
getch();
}
Output
PRINTING UPPERCASE AND LOWER CASE ALPHABETS |
Explanation
In the program, the for loop will be executed as follows:
n(1 to 26) capital small Output screen
n(1 to 26) capital small Output screen
1 A a Aa
2 B b Bb
3 C c Cc
. . . .
. . . .
2 B b Bb
3 C c Cc
. . . .
. . . .
. . . .
26 Z z Zz
The post-increment operator will alter the value of variables(capital++ and small++) only after their values are printed. In this way, we obtain our required output on the screen.
No comments:
Post a Comment