If_Age_A

If_Age_A - else if age< 20 If the age is less than 20...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// example to demonstrate use of a multi-alternative if statement / #include <iostream> # using namespace std; u int main() { int age; cout << "Enter your age: " ; cin>> age; if ( age <= 0 ) // Verify age is positive cout <<"I guess you are not born yet.\n"; else if (age > 150) // Verify age is not too big cout <<"I cant believe you are that old!!!!!!!!.\n"; else if ( age == 100 ) // Check for century mark cout << "WOW, Congradulations, You are a century old."<<endl;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: else if ( age < 20 ) // If the age is less than 20 cout <<" You are pretty young!\n"; // Just to show you it works. .. else if ( age < 50) cout <<"You still have a few good years left in you." << endl ; else if (age < 62) cout <<"Enjoy your retirement, you have earned it." << endl ; else if ( age > 100 ) // I use else just to show an example cout<<"You are really old\n"; // Executed if no other statement is return 0 ; }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online