One day while Cody was playing with his friends in the woods, they stumbled upon a bearded old man living alone in his cabin. Cody and his friends were shocked that somebody could grow that old. Cody, refusing to believe that it is possible, asked the old man his age. The old man said, "My age is the sum of The Programmer and your teacher's ages subtracted by the age of your friend, Peter". Puzzled with this statement, Cody quickly tried to input the ages of The Programmer, his teacher, and his friend, Peter. Help Cody find out the age of the old man.
#include <iostream>
using namespace std;
int main()
{
int progAge, teachAge, PetAge;
cout << "Please, enter The Programmer`s age: ";
cin >> progAge;
cout << "Please, enter teacher's age: ";
cin >> teachAge;
cout << "Please, enter Peter's age: ";
cin >> PetAge;
cout << "The age of the old man is " << PetAge - (progAge + teachAge);
}
Comments
Leave a comment