#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
usingnamespace std;
int main()
{
char input[1];
int x = rand() & 25;
int y = rand() & 25;
int a = x+y;
int answer;
cout<<"This program is a simple test. You must add 2 random numbers.\n\n";
do {
cout<<"The question is: " << x << "+" << y << "= ";
cin>>answer;
cout<<"\n\n";
if (answer == a){
cout<<"Correct!\n\n";
cout<<"Would you like to try a new problem? (y/n): ";
gets(input);
}
elseif (answer != a) {
cout<<"Incorrect!\n\n";
cout<<"Would you like to try again? (y/n): ";
gets(input);
}
} while (strcmp (input, "y") == 0);
cout<<"Okay.";
cin.get();
}
Well first you can stop using gets and continue to use cin to get input cin >> input;
Then you can change input to be a single char instead of an array of a single char.......
Then you can just compare input directly to the character 'y' instead of using strcmp input == 'y'
btw rand() will continue to return the exact same values because you're never seeding it