Help with Yes or No question

One of my first programs. Just a simple one that'll keep asking me my age until I say no "N" i dont want to try again or I guess right. I know it's lame, but any help would be much appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <cstdio>
#include <cstdlib> //honestly, I don't know anything about these
#include <time.h>
#include <fstream>
using namespace std;

int main()
{
int age;
int response;
   cout << "How old are you today?" << endl;
   cin >> age;

if (age == 28)
   {
    cout << "Thats Right!"<< endl; return 0;
    }

else if (age != 28)
    {
        cout << "Thats not true! Do you want to try again? (Y/N)" <<endl;
cin >> response;     //Right here is where it quits running the program.  I can't figure out why.

if (response == 'Y')
{
cout <<"Sweet" <<endl;
}
else if (response == 'N')
{
cout << "Ok. Maybe next time" <<endl;
}                //Eventually I want to get it to loop back to the intial question, but right now I'll be happy to get it to <cout> the respective response.
}
return 0;
}



I think you want to declare response as a char. Try that.
Thanks! I've been racking my head on this for a couple hours now.
Topic archived. No new replies allowed.