- #1
Teh
- 47
- 0
I am not sure if should i use a for loop or if statement...may anyone give me a hint what i am suppose to do?Use function GetUserInfo to get a user's information. If user enters 20 and Holly, sample program output is:
Holly is 20 years old.
Testing with inputs 20 and Holly
Expected output: Holly is 20 years old.
Your output: is 0 years old.
Holly is 20 years old.
Code:
#include <iostream>
#include <string>
using namespace std;
void GetUserInfo(int& userAge, string& userName) {
cout << "Enter your age: " << endl;
cin >> userAge;
cout << "Enter your name: " << endl;
cin >> userName;
return;
}
int main() {
int userAge = 0;
string userName = "";
/* Your solution goes here */
cout << userName << " is " << userAge << " years old." << endl;
return 0;
}
Expected output: Holly is 20 years old.
Your output: is 0 years old.