A simple program I did for completing an exercise:
Code:
//This program reads the <char> from the keyboard, and then displays one of the following messages:/* 1. If <char> is a lower case letter, the message is
"The upper case character correspond to <char> is ___. "
2. If <char> is an upper case letter, the message is
"The lower case character correspond to <char> is ___. "
3. If <char> is not a letter, the message is
"<Char> is not a letter. */
#include <iostream>
using namespace std;
int main()
{
char letter;
//prompt the user for letter
cout << "Type in any letter:\n";
cin >> letter;
cout << "\n";
//print the appropriate message
if (letter >= 65 && letter <=90)
cout << "The lower case character corresponds to '" << letter <<"' is " << (char)(letter + 32) <<".\n";
else if (letter >= 97 && letter <=122)
cout << "The upper case character corresponds to '" << letter <<"' is " << (char)(letter - 32) << ".\n";
else
cout << "The character '" << letter <<"' is not a letter.\n";
system("pause");
return 0;
}
Notice that I put However, the example answer given for the question number 3 @ C++ EXERCISES 2 is
this http://www.doc.ic.ac.uk/~wjk/C++Intr...illerEA2-3.cpp.
Can you please tell me why he/she alter the line to this??
Thank you.