hi,how are you?
I wanna understand in the code listed below what does 3 things mean?
1:char Exit='N';
What does it mean?
2:while(toupper(Exit)!='Y')
What does it mean??
3:somewhere in the code we write: while(9>0)
i just wanna know why do we put this?
#include <iostream.h>
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
int main()
{
char Exit='N';
cout<<" *_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_ *_*_*_*_*_*_*_*_*\n";
cout<<" *_*_*_*_*_*_*_*_*_*_*_*_Welcome to the Number machine*_*_*_*_*_*_*_\n";
cout<<" *_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_ *_*_*_*_*_*_*_*_*\n";
while(toupper(Exit)!='Y')
{
int Answer;
int Count=1;
int Number;
srand((unsigned)time(NULL));
Number=(rand()%99)+1;
cout<<" \n";
cout<<"\n";
cout<<"\n";
cout<<"1. I'm thinking of a number between 1 and 100\n";
cout<<"What is my Number?";
cin>>Answer;
while (9>0)
{
if ((Answer<1) ||(Answer>100))
{
cout<<"Nope,i said a number between 1 and 100\n";
Count=Count+1;
}
else if (Answer==Number)
{
cout<<"Good Job!"<<endl
<<"You won in "<< Count <<" tries!!"<<endl;
break;
}
//too high
else if (Answer>Number)
{
cout<<"Too High!!\n";
Count=Count+1;
}
//too low
else if (Answer <Number)
{
cout<<"Too Low!!\n";
Count=Count+1;
}
cout<<"What is my Number?";
cin>>Answer;
}
cout<<"Now press 'Y' to quit or 'N' to play again:";
cin>>Exit;
}
}