Need Help Please!

How would i revise this program to randomly generate an addition question with two integers less than 100. I am new to this and would appreciate any help! Thanks!



#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

int main()
{
// Generate two random single-digit integers
srand(time(0));
int number1 = rand() % 10;
int number2 = rand() % 10;

// If number1 < number2, swap number1 with number2
if (number1 < number2)
{
int temp = number1;
number1 = number2;
number2 = temp;
}

// Prompt the student to answer "What is number1 - number2?"
cout << "What is " << number1 << " - " << number2 << "? ";
int answer;
cin >> answer;

// Grade the answer and display result
if (number1 - number2 == answer)
cout << "You are correct!";
else
cout << "Your answer is wrong.\n" << (number1 << " - " << number2)
<< " should be " << (number1 - number2) << endl;

return 0;
}
rand() % 10
---------------
rand() % 100
On line 30 it says there is an illegal right operand (<<) and i cant figure out why it is saying that...
You shouldn't have the "(" character there. Either enclose it in double quotes if you want it to display or get rid of it if it is extra.
Topic archived. No new replies allowed.