//flag controlled while loop
//number guessing game
#include<iostream>
#include<cstdlib>
#include<ctime>
usingnamespace std;
int main()
{
int num,guess;
bool isguessed;
srand(time(0));
num=rand()%100;
isguessed=false;
while(!isguessed)
{
cout<<"Enter an integer greater than or equal to 0 and less than 100: ";
cin>>guess;
cout<<endl;
}
if(guess==num)
{
cout<<"you guessed the correct "<<"Number."<<endl;
isguessed=true;
}
elseif(guess<num)
{
cout<<"your number is lower than the "<<"number.\n guess again!"<<endl;
}
return 0;
}
Please put your code within code tags. Then we can see the indentation that you (hopefully) are using to clarify code structure.
what does this mean, i am new here. Will you please tell me about this.
The forum has a stupid bug that prevents the user from clicking the code tag button in the Original Post.
But you can edit your post and either manually add "[code] [/code]" surrounding your code, or highlight your code and press the [<>] button in the Format section.
#include <whatever>
int main()
{
code code code;
}
Or: See the "Format" section to the right-hand side of the posting field?
Highlight your code with your mouse, and then click the button with the <> symbol in it.