Code so far:
Code:
#include <iostream>
#include <cstdlib>
using namespace std;
int main(void){
int a, b, c,d,n, guess;
cout << "enter a range of number to guess from.\n";
cin >> a >> b;
d = rand() ; // need to make this within range entered by user
cout << d;
cout << "how many guesses do you want?\n";
cin >> c;
for (int i=0; i<c; i++){
cout << "Enter a guess:\n";
cin >> guess;
if(guess == d){
cout << "You got it!\n";
return 0;
}
else if(guess < d)
cout << "too low\n";
else
cout << "too high\n";
}
}
I need the random number to be within the range the user enters. I don't get how. I read about rand() %10 is 0-9.. but how do i use the users input to create a random number within their range.
thanks.