
May 2nd, 2006, 11:05 PM
|
 |
Registered Loser
|
|
Join Date: Jul 2005
Location: Retardation Nation...
Posts: 347

Time spent in forums: 4 Days 3 h 13 m 45 sec
Reputation Power: 4
|
|
I made the same program in C++ but it only has addition to show you how you could possibly accomplish this using random numbers. Ubergeek gave a good link to showing you how to use them as well, and that site is good for just about any function you need to know about
Code:
int main ()
{
int choice = 0,first = 0,second = 0,answer = 0,rand1 = 0,rand2 = 0,correct = 0;
int seed;//random number generator.
float percentage = 0.0;
char finish;
do
{
cout<<"Please choose a function\n"
<<"1] Addition\n"
<<"2] Subtraction\n"
<<"3] Division\n"
<<"4] Multiplication\n";
cin>>choice;
if(choice == 1)
{
seed = time(NULL);
srand(seed);//generator
rand1 = rand() % 1000 + 1;
rand2 = rand() % 1000 + 1;
do
{
cout<<rand1<<" + "<<rand2<<" = ";
cin>>answer;
if(answer == (rand1 + rand2))
{
correct = 1;
}
}
while(correct == 0);
cout<<answer<<" is correct.\n";
}
cout<<"Would you like to choose another function (Y/N): ";
cin>>finish;
}
while(finish == 'Y' && finish == 'y');
system("Pause");
return 0;
}
I found that if you use a newer compiler and include the iostream library and using namespace std; you can just use the rand() function for almost the same result, but try for yourself and see. you just have to change the cout and cin statements to your printf and scanf to make this work in C. 
__________________
---Official Member Of The Itsacon Fan Club---
Give a man a fish and he will eat for a day. Teach a man to fish and he will sit in a boat all day drinking beer.
|