I am having issues with the code I am currently writing. I am trying to get and if else statement to work with the word True, and then if true count up a value. I'll post what I have so far, I took a break because I was frustrated. I just changed True, False, and answer to string, but previously tried char, and bool, but nothing has worked. I also cannot find info, because i just keep getting basic if true blah if false blah info on google. Any help would be appreciated. Thanks! Oh also the project is supposed to be a guessing game where they guess true or false otherwise I would have just used 1 and 2 or something.
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
int x;
int y;
int answer;
string True;
string False;
string Answer;
x=0;
y=0;
cout<< "Would you like to play a game? Type 1 to play, or 2 to terminate."<< endl;
cin >> answer;
if (answer == 1)
{printf("Excellent.\n");}
else {printf("Bummer.\n"); return 0;}
cout << "Evaluate the folowing proverbs. Answer True if the proverb is correct, or False if the proverb is incorrect then hit enter. At the end of the game we will rate your performance.\n" << endl;
cout << "True or False: The squeaky wheel gets the grease.\n" << endl;
cin >> Answer;
if (Answer = "True")
{y = x++;}
else {y= x+0;}
cout << "Your final score is: " << y << endl;
so the first return 0 is if they type 2, which works, and the program continues if you type 1. Can you give me an example of pre-increment? I am taking a C++ class, and we haven't used the counting up stuff yet.
Cool it now works correctly. Am I right to assume, that I could accomplish this only with x and whenever the question is answered correctly x= ++X? so on and so on?