I'm new to C++, and I'm trying to create a program that will use an algorithm which adds two random numbers that I have generated within a specified range. I have generated two random numbers, each with a different range, but I keep getting the same error no matter how I try to define the variables that I am using to range the random numbers to. Here's the part of the code I am referring to:
srand ((unsigned)time(0));
int AddNum1; //Define the variable of the random number to limited between 100 and 300
int AddNum2; //Define the second variable of the random number to be between 0 and 100
int correct;
int AddAnswer;
switch (HELP) //A switch will be used to navigate through the choices from the menu
{
case 1: srand((unsigned)time(0));
AddNum1 = rand() % 200 + 100; //Setting the range to the first random int
cout << setw(4) << rand() << endl;
srand((unsigned)time(0));
AddNum2 = rand() % 101; //Seeting the range for the second random int
cout << "+";
cout << setw(3) << rand () << endl;
cout << setw(4) << "---" << endl;
cout << correct = AddNum1 + AddNum2;
cin >> correct;
In bold is where the error appears. The error reads: error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(584): could be 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator =(const std::basic_ostream<_Elem,_Traits> &)' etc.