I'm writing a program where
1. ask the user to enter two integers
2. the computer will randomly select a number between those two integers (inclusive)
3. the computer will then ask the user to guess the number it selected then:
a.say if it's too high or too low if it's wrong
b.print that the guess is correct and say the number or guesses it took if it was right
I need help starting out the program in how the computer will select a random number between the numbers the user inputs
My teacher told me to first do an if statement with if(n1 > n2) and if it's true :
temp = n1;
n1 = n2;
n2 = temp;
and if it's false pick a random number
This is supposed to check if the user didn't input the same number right?
CODE
#include <cstdlib>
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
int n1;
int n2;
int count = 0;
int temp;
cout << "Please enter two integers: " << endl;
cin >> n1 >> n2;
cout << endl;
if (n1 > n2)
{
temp = n1;
n1 = n2;
n2 = temp;
}
This post has been edited by cyril27cherian: 4 Oct, 2008 - 09:58 AM