N
Naya
Hi. I am working on a math tutoring program which generates two random
numbers (from 1 to 500) and asks the user to add them. How can I check
to see whether or not they put in the correct total?? How do you add
random numbers that are generated anyway??
#include <iostream>
#include <cstdlib>
#include <time>
#include <conio>
using namespace std;
int main()
{
unsigned seed;
cout << "Enter a seed value: " ;
cin >> seed;
srand(time(0));
cout << rand()%500 << endl;
cout << rand()%500 << endl;
cout << rand()%500 + rand()%500;
getch();
return 0;
}
Enter a seed value: 1
385
425
644
numbers (from 1 to 500) and asks the user to add them. How can I check
to see whether or not they put in the correct total?? How do you add
random numbers that are generated anyway??
#include <iostream>
#include <cstdlib>
#include <time>
#include <conio>
using namespace std;
int main()
{
unsigned seed;
cout << "Enter a seed value: " ;
cin >> seed;
srand(time(0));
cout << rand()%500 << endl;
cout << rand()%500 << endl;
cout << rand()%500 + rand()%500;
getch();
return 0;
}
Enter a seed value: 1
385
425
644