I have to prompt the user to enter their name and their height using two separate inputs, one for feet and one for inches. Then I have to display what they entered. Ex: Name, you are x feet y inches tall. The program I wrote runs but it's not working as intended. After I write an input for the first question which is the name, the program skips the other questions and ends the program.
#include <iostream>
#include <string>
using namespace std;
int main ()
{
int name;
int f;
int i;
// Start: Enter Name
cout << "What is your name?" << endl;
cin >> name;
// Enter height
cout << "How many feet tall are you tall?" << endl;
cin >> f;
// Enter inches
cout << "How many inches tall are you after feet?" << endl;
cin >> i;
// End: All info entered
cout << name << " you are " << (f) << " feet " << (i) << " inches tall." << endl;
system("pause");
return 0;
}
cin >> name;you can only enter the first name. If you enter a space the part after will go to the next cinstd::string name;as the name variable?int