tutorial test problem

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <string>
#include <iostream>

using namespace std;

int main ()
{
   cout << "Please enter your first name and age\n";
   string first_name;
   int age;
   cin >> first_name;
   cin >> age;
   cout << "Hello," <<first_name<< "(age"<<age<<")\n";
   return 0;

}

I dont understand how to turn age into months. well...i know how ...but not sure how to pinpoint turning into code?
my failed attempt looks like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <string>
#include <iostream>

using namespace std;

int main ()
{
   cout << "Please enter your first name and age\n";
   string first_name;
   int age;
   int ageMonth;
   cin >> first_name;
   cin >> age;
ageMonth = age * 12;
   cout << "Hello," <<first_name<< "(age"<<age<<")\n";
   return 0;

}
my failed 2nd attempt:
[code#include <string>
#include <iostream>

using namespace std;

int main ()
{
cout << "Please enter your first name and age\n";
string first_name;
int age;
int ageMonth;
cin >> first_name;
cin >> age;
age <<(ageMonth * 12);
cout << "Hello," <<first_name<< "(age"<<age<<")\n";
return 0;

}
][/code]
Re-read the section on variables and data types. Specifically the part on how to assign values to variables.
Topic archived. No new replies allowed.