So far I've got the code to display
Enter a character: a
a is the 1 in the alphabet
but I was wondering how it'd be possible to output the actual word(first, second, third..)?
User a letter of the alphabet either upper or lowercase the code tells him which letter it is
For example:
'A’ ➔ "'A' is the first letter of the alphabet
'b’ ➔ "'b' is the second letter of the alphabet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include<iostream>
usingnamespace std;
int main ()
{
char c;
char num;
cout << "Enter a character : ";
cin >> c;
if (c >= 'A' && c <= 'Z')
num = c - 'A';
elseif (c >= 'a' && c <= 'z')
num = c - 'a';
cout<<c<<" is the " <<(int) num+1<<" in the alphabet"<<endl;
return 0;
}