You will get the the same number from rand() each time.
Also, this code:
if(guess==number)
cout<<"You guessed the
number";} <<<<<<<<??
else
cout<<"Sorry, the number was:
"<<number;
looks like it has unbalanced braces.
I would code it as:
-
if(guess==number)
-
{
-
cout<<"You guessed the
-
number";
-
}
-
else
-
{
-
cout<<"Sorry, the number was:
-
"<<number;
-
}
-
This way there is no confusion.
Also, you have literals spanning lines. For example,
cout<<"You guessed the
number";
and that won't compile in C++. You can continue a litreral from one line to the next but you have to have each section with it's own double quotes:
-
[quote=scrip99]
-
cout<<"You guessed the"
-
"number";
-