Hi, I'm writing a program that find the largest and lowest number from inputted values but I don't know how to get the program to do it.
See below the code I have so far:
Code:#include(iostream) using namespace std; int bob,tim,harry,jon; do { cout << "Enter BOB'S age: "; cin >> bob; if (bob<0) { cout << "Error, number cannot be under 0"; } } while (bob<0) do { cout << "Enter JIM'S age: "; cin >> jim; if (bob<0) { cout << "Error, number cannot be under 0"; } } while (bob<0) do { cout << "Enter TIM'S age: "; cin >> tim; if (tim<0) { cout << "Error, number cannot be under 0"; } } while (tim<0) do { cout << "Enter HARRY'S age: "; cin >> harry; if (harry<0) { cout << "Error, number cannot be under 0"; } } while (harry<0) }
How could I get the program to find the highest AND lowest aged people. Do I need to totally change this code?
This is what I would like it to look like:
Thanks in advance for your helpCode:Enter BOB'S Age: 45 Enter JIM'S Age: 64 Enter TIM'S Age: 22 Enter HARRY'S Age: 65 The oldest fellow is: HARRY at 65 The youngest fellow is: TIM at 22




Reply With Quote