Re: Program to enter a letter and output the next 2 letters
But a good programmer will consider A-z & a-z as characters for a sequence.
The code above will give "[" after Z and '{' after z ,although its a character but it dosnt make any sense .
#include <iostream.h>
#include <conio.h>
void main()
{
{
clrscr(); //This clrscr produces wastege in systems performance
char charac;
cout << "Enter your char : " << endl;
cin>>charac;
cout << "The 2 letters are : " << endl;
if (((char)(charac) <=90 && (char)(charac) >= 66 ) | (char)(charac) <=122 && (char)(charac) >= 98 )// this line can simply be replaced by if (charc != 'a' | charc!='A')
cout << (char)(charac-1) << endl;
else
cout << "There is no char Before "<<(char)(charac)<< endl;
if ((char)(charac) <=89 && (char)(charac) >= 65 | (char)(charac) <=121 && (char)(charac) >= 97 )
cout << (char)(charac+1) << endl;
else
cout << "There is no char After"<<(char)(charac)<< endl;
getch();
}//end main function
}
|