dos_compilers/Borland Turbo C++ v1/EXAMPLES/EX2.CPP
2024-07-02 07:34:51 -07:00

26 lines
645 B
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ex2.cpp: An interactive example
// from Chapter 6 of User's Guide
#include <iostream.h>
main()
{
char name[16];
int age;
cout << "Enter your name: ";
cin >> name;
cout << "Enter your age: ";
cin >> age;
if (age < 21)
cout << "You young whippersnapper, " << name << "!\n";
else if (age < 40)
cout << name << ", you're still in your prime!\n";
else if (age < 60)
cout << "You're over the hill, " << name << "!\n";
else if (age < 80)
cout << "I bow to your wisdom, " << name << "!\n";
else
cout << "Are you really " << age << ", " << name << "?\n";
}