EDIT: Wow a lot of people beat me to the punch I guess ^_^
The way you have it with the semi-colon after your if statements, the program does this:
reads in the first char of the response (y or n)
is the response 'y'? if so, do nothing.
Now....
print "You are coorect!" to console.
is the response 'n'? if so, do nothing.
Now....
print "You are wrong :DDDDD" to screen.
screen ends up saying:
1 2
|
You are coorect!"
You are wrong :DDDDD
|
and exits.
Do you understand the flow of logic there?
It is more important to understand than to get the right answer.
I fixed it for you. Have fun.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include<iostream>
#include<string> // why include <stdio.h> ??
using namespace std;
int main()
{
char response;
cout << "Is Vigo stupid?(Y or N?)" << endl;
cin >> response;
response = toupper(response); // make it toupper to begin with, so you know it will be upper when compared below
if (response == 'Y') // no ';' after these!
cout << "You are coorect!" << endl;
else if (response == 'N') // again, no ';'
cout << "You are wrong :DDDDDDD" << endl;
cin.get();
cout << "Press enter to continue"; // formalities
cin.get(); // pause console
return(0);
}
|