Well, Im very new to C++. Ive made very simple projects lately and I thought i could give a game a try. As my first game I wanted to go a simple as possible. A guess the number game. The problem is with the random number generating. I'm not good at generating random numbers at all... The part always generates 1 when it should be picking 1 between 1 and 5. How can I fix this. Here is the entire code.
#include <iostream>
usingnamespace std;
int main()
{
int number;
int guess;
number = rand() % 5;
cout << "A Random number between 1 and 5 has been generated. Try and guess it." << endl;
cin >> guess;
if (guess == number)
{
cout << "Good job! You correctly Guessed the Number!" << endl;
}
elseif (guess != number)
{
cout << "That number is incorrect!" << endl;
}
}