When I type yes or no, the "You are coorect!" and "You are wrong :DDDDDDD" appear at the same time, how do I make my program make the text appear when I type yes?
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.
#include<iostream>
#include<string> // why include <stdio.h> ??
usingnamespace 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;
elseif (response == 'N') // again, no ';'
cout << "You are wrong :DDDDDDD" << endl;
cin.get();
cout << "Press enter to continue"; // formalities
cin.get(); // pause console
return(0);
}
Ohh and I included <stdio.h> because I use getchar() at the last bit of my program (before return 0;) but thanks for your awesome help and clearing things up with the logic!