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.
#include <iostream>
#include <cstdio>
#include <cstdlib> //honestly, I don't know anything about these
#include <time.h>
#include <fstream>
usingnamespace 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;
}
elseif (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;
}
elseif (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;
}