Problem with repeating question code

I begun learning c++ yesterday when I was bored in the afternoon..

I am currently messing around with the following code..


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

int main()

{

     std::cout << "What is your name? ";
     char yourname [80];
     std::cin >> yourname;
     std::cout << "Hello " << yourname << "! " ;
     std::cout << "How old are you " << yourname << " ? ";
     int age1;
     std::cin >> age1;
     std::cout << "So your name is " << yourname << " and you are " << age1 << " years old? ";

return 0;

}


What I am trying to get it to do at the end there is for the user to input yes or no. If it's yes it asks the next question. However if it's no it repeats the first two questions.

Can someone point me in the right direction for the code I should be using? I've been stuck on this for almost an hour :(
Use a loop, the do-while seems the most appropriate in your case
http://www.cplusplus.com/doc/tutorial/control/#do
Topic archived. No new replies allowed.