Ask user for 3 integers

I need to prompt the user for two positive integers; then prompt for a number

between those numbers. If the number entered is between the first two, then

display the words "Good Job!". Here is all I have so far:

#include <iostream>
using namespace std;

int main()
{
int i;
int j;
cout << "Please enter a number: ";
cin >> i;
cout<< "Please enter a number: ";
cin>>j;
if (i)
{
cout << "Good Job" << endl;
}
else
{
cout << "YOU LOSE" << endl;
}
return 0;
}
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!!!
Sorry I missed a closing quote " after between in line 8.
It should read cout<< "Please enter a number between "<< i << " and " << j << ": ";
I made it more user friendly.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace 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
Topic archived. No new replies allowed.