Currently you're only prompting for two inputs.
Try this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
int main()
{
int i,j,k;
cout << "Please enter a number: ";
cin >> i;
cout<< "Please enter a number: ";
cin>>j;
cout<< "Please enter a number between << i << " and " << j << ": ";
cin>>k;
if (k > i && k < j) //if i < k < j
{
cout << "Good Job" << endl;
}
else
{
cout << "YOU LOSE" << endl;
}
return 0;
}
This prompts the user to enter a number between the first two entered numbers. It the checks whether it fills the condition of i < number < j. If it does then "Good job". If not "YOU LOSE"
Thanks for the update. I put this in and still seem to be missing something. Should there be a ';' before identifier 'and'? THat is the error I am getting. Thanks!!!
#include <iostream>
usingnamespace std;
int main()
{
int i,j,k;
cout << "Please enter a number:\n> ";
cin >> i;
cout<< "Please enter a number:\n> ";
cin>>j;
cout<< "Please enter a number between " << i << " and " << j << ":\n> ";
cin>>k;
if (k > i && k < j) ///if i < k < j
{
cout << "Good Job!" << endl;
}
else
{
cout << "You Failed!" << endl;
}
return 0;
}
Thanks both danghotties and jasonwynn10. This was very helpful! One more question. Do i put this in a loop if I want to keep asking the user if he she wants to play again after each time? For example after he/she puts in the number and the response you win or you lose comes up can I ask Do you want to play again (yes/no)? THanks