First program. Need help.
I know this is one of the simplest programs ever, but I need help because I'm new to C++.
Code:
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
int num;
int inputnum;
num = rand()%101;
cout<<"Pick a number between 0-100"<<endl;
cin>>inputnum;
if(inputnum == num)
{
cout<<"Your right! The number is "<<num<<endl;
}
while(inputnum > num)
{
cout<<"Try a little lower"<<endl;
cin>>inputnum;
}
while(inputnum < num)
{
cout<<"That's too low."<<endl;
cin>>inputnum;
}
return 0;
}
1st problem: it picks 1 number then it's the same all the time
2nd problem: after 3 guesses it closes
the compiler I'm using is VC++