1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
#include <iostream>
#include <ctime>
void Multiplication(double a, double b,double &l);
void addition(double a, double b,double &m);
void division(double a, double b,double &d);
void subtraction(double a, double b,double &s);
double answer = 0 ;
using namespace std;
int main()
{
double a = (rand() % 10) + 1;
double b = (rand() % 10) + 1;
double i;
double l,m,d,s ;
cout<<"\n\n This is a Program to teach Elementary Students how to do Mathmatical Operations \n\n";
cout<<"\n\nPress 1 for Multiplication , 2 for addition , 3 for division ,and 4 for subtraction\n\n";
cin>>i;
if(i == 1)
cout<<Multiplication(a,b,l)<<endl;
else if (i = 2)
cout<<addition(a,b,m)<<endl;
else if (i = 3)
cout<<division(a,b,d)<<endl;
else if (i = 4)
cout<<subtraction(a,b,s)<<endl;
return 0;
}
void Multiplication(double a, double b,double &l)
{
cout<<"\n\n Multiplication \n\n";
cout<< "What is "<< a << " times " << b << " ? "<<endl;
cin>> answer;
if(answer ==(a*b))
{
cout<< "Very Good!!\n"<<endl;
a= rand()%10;
b= rand()%10;
}
else{
cout<<"No, Please try again.\n"<<endl;
}
}
void addition(double a, double b,double &m)
{
cout<<"\n\n addition \n\n";
for (int x=0 ; x!=1 ; x){
cout<< "What is "<< a << " plus " << b << " ? "<<endl;
cin>> answer;
if(answer ==(a+b))
{
cout<< "Very Good!!\n"<<endl;
a= rand()%10;
b= rand()%10;
}
else
cout<<"No, Please try again.\n"<<endl;
}
}
void division(double a, double b,double &d)
{
cout<<"\n\n division \n\n";
for (int x=0 ; x!=1 ; x){
cout<< "What is "<< a << " divided by " << b << " ? "<<endl;
cin>> answer;
if(answer ==(a/b))
{
cout<< "Very Good!!\n"<<endl;
a= rand()%10;
b= rand()%10;
}
else
cout<<"No, Please try again.\n"<<endl;
}
}
void subtraction(double a, double b,double &s)
{
cout<<"\n\n subtraction \n\n";
for (int x=0 ; x!=1 ; x){
{
cout<< "What is "<< a << " minus " << b << " ? "<<endl;
cin>> answer;
if(answer ==(a-b))
{
cout<< "Very Good!!\n"<<endl;
a= rand()%10;
b= rand()%10;
}
else
cout<<"No, Please try again.\n"<<endl;
}
}
|