The guessing game

hello everyone
I'm in my first year studying computer science at Southampton uni
we been given this code and have to figure out why it always equals 2
uncomfortably I cant get my head around this one :(
can any one help me?

Heres the code;

Guessing game.
#include <iostream>
#include <string>
using namespace std;
int main()
{
int num = (rand() % 10) + 1;
int guess = -1;
while (guess != num)
{
cout << "Enter your guess (1-10): ";
cin >> guess;
if (guess < num)
cout << "Higher!" << endl;
else if (guess > num)
cout << "Lower!" << endl;
else
cout << "Winner!" << endl;
}
system("pause");
return 0;
}

Thank you!!
Topic archived. No new replies allowed.