topical media & game development
basic-program-code-03-Ex3-01.c
? /
basic-program-code-03-Ex3-01.c
// Ex3_01.cpp
// A nested if demonstration
include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main()
{
char letter = 0; // Store input in here
cout << endl
<< "Enter a letter: "; // Prompt for the input
cin >> letter; // then read a character
if(letter >= 'A') // Test for 'A' or larger
if(letter <= 'Z') // Test for 'Z' or smaller
{
cout << endl
<< "You entered a capital letter."
<< endl;
return 0;
}
if(letter >= 'a') // Test for 'a' or larger
if(letter <= 'z') // Test for 'z' or smaller
{
cout << endl
<< "You entered a small letter."
<< endl;
return 0;
}
cout << endl << "You did not enter a letter." << endl;
return 0;
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.