Thanks!
int main (){
int i = 1;
int ans;
while(i<=10)
{
cout<<"What is 2 times " <<i <<endl;
cin>>ans;
if(ans !=i*2)
cout<<"Try again" <<endl;
else i++;
}
return 0;
}




Posted 04 October 2012 - 02:40 PM
int main (){
int i = 1;
int ans;
while(i<=10)
{
cout<<"What is 2 times " <<i <<endl;
cin>>ans;
if(ans !=i*2)
cout<<"Try again" <<endl;
else i++;
}
return 0;
}
Posted 04 October 2012 - 02:43 PM
Posted 04 October 2012 - 02:51 PM
int main (){
int i = 1; //may need to make another counter variable.
int ans;
while(i<=10)
{
cout<<"What is 2 times " <<i <<endl;
cin>>ans;
/*******Change this if statement to a while loop*********/
//initialize any new variables
if(ans !=i*2) //while(ans!=i*2&&SomeOtherCondition){
cout<<"Try again" <<endl;
/*add the following lines*/
//cout<<"What is 2 times " <<i <<endl;
//cin>>ans;
//increment any new variables
//}
else i++; //Will no longer need else. just i++;
/********************************************************/
}
return 0;
}
This post has been edited by mojo666: 04 October 2012 - 02:51 PM
Posted 05 October 2012 - 04:23 AM
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
