// Objective: Guess the correct answer of the random numbers
// Problem: I guess the correct answer but the program keeps telling me that
// I'm INCORRECT.
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(int argc, const char * argv[])
{
const int MIN_VALUE = 1; // Constants
const int MAX_VALUE = 200;
int num_1, num_2, total; // Variables
char ch;
unsigned short seed = time(0); // System time
if (cin.get() == total)
{
cout << "That is the correct answer!" << endl; //<--PROBLEM
}
else
{
cout << "That is an incorrect answer. The correct answer is " << total << endl;
}
return 0;
}
You are reading in a single character and trying to compare it to a number that is probably more than 1 character and anyways you would be comparing the ascii value of any digit entered to the added value. I would also suggest you make the input/output more user friendly such as