I'm making a beginner guess the number in Microsoft Visual Studio 2015. How do I make it say something else if the guessed number is not the same as the randomly generated number? When I run the program and guess, It says both of the "if << cout." Could I have some help, I never really got the whole "if else" statements.
#include <iostream>
#include <ctime>
#include <random>
#include <string>
using namespace std;
int main() {
int guessNumber;
int guess;
mt19937 numGen(time(NULL));
uniform_int_distribution<int> findNum(1, 10);
cout << "Welcome to Guess the Number\n" << endl << "Your Guess : ";
cin >> guess;
if (guess = findNum(numGen)) {
cout << "\nNice Job" << endl;
}
else if (guess != findNum(numGen)) {
cout << "\nGood Try" << endl;
}
system("PAUSE");
return 0;
}
Aucun commentaire:
Enregistrer un commentaire