Okay dudes, I have this program and when I run it I need it to generater random numbers, but I can't seem to figure out how to use the srand() thing to do it. Thank for the help in advance.
Code:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
bool TrueFalse1, TrueFalse2, TrueFalse3, TrueFalse4, TrueFalse5;
long int xNumber = 1 + rand() % 50,
yNumber = 1 + rand() % 50,
A = 1 + rand() % 50,
B = 1 + rand() % 50,
C = 1 + rand() % 50,
result1, result2, result3, result4, result5,
answer1, answer2, answer3,answer4,answer5,
result,
total,
x = xNumber,
y = yNumber;
cout<<"Solve the following expression where x = "<<xNumber << " and y = "<<yNumber<<endl;
cout<<A<<" x + "<<B<<" y + "<<C<<endl;
cout<<"Write your result:\n";
cin>> result1;
answer1 = (A * x) + (B * y) + C;
if (result1 == answer1)
cout<<"Your answer is correct\n";
else
cout<<"Your answer is wrong. The correct answer is "<<answer1<<endl;
TrueFalse1 = (result1 == answer1);
cout<<"Solve the following expression where x = "<<xNumber<<" and y = "<<yNumber<<endl;
cout<<A<<" x + "<<B<<" y + "<<C<<endl;
cout<<"Write your result:\n";
cin>> result2;
answer2 = (A * x) + (B * y) + C;
if (result2 == answer2)
cout<<"Your answer is correct\n";
else
cout<<"Your answer is wrong. The correct answer is "<<answer2<<endl;
TrueFalse2 = (result2 == answer2);
cout<<"Solve the following expression where x = "<<xNumber<<" and y = "<<yNumber<<endl;
cout<<A<<" x + "<<B<<" y + "<<C<<endl;
cout<<"Write your result:\n";
cin>> result3;
answer3 = (A * x) + (B * y) + C;
if (result3 == answer3)
cout<<"Your answer is correct\n";
else
cout<<"Your answer is wrong. The correct answer is "<<answer3<<endl;
TrueFalse3 = (result3 == answer3);
cout<<"Solve the following expression where x = "<<xNumber<<" and y = "<<yNumber<<endl;
cout<<A<<" x + "<<B<<" y + "<<C<<endl;
cout<<"Write your result:\n";
cin>> result4;
answer4 = (A * x) + (B * y) + C;
if (result4 == answer4)
cout<<"Your answer is correct\n";
else
cout<<"Your answer is wrong. The correct answer is "<<answer4<<endl;
TrueFalse4 = (result4 == answer4);
cout<<"Solve the following expression where x = "<<xNumber<<" and y = "<<yNumber<<endl;
cout<<A<<" x + "<<B<<" y + "<<C<<endl;
cout<<"Write your result:\n";
cin>> result5;
answer5 = (A * x) + (B * y) + C;
if (result5 == answer5)
cout<<"Your answer is correct\n";
else
cout<<"Your answer is wrong. The correct answer is "<<answer5<<endl;
TrueFalse5 = (result5 == answer5);
total = TrueFalse1 + TrueFalse2 + TrueFalse3 + TrueFalse4 + TrueFalse5;
cout<< "You answered "<<total<<" correctly.\n";
return 0;
}