Math Tutor

08:49 2 Comments A+ a-

Problem:
Write a program that can be used as a math tutor for a young student. The program should display two random numbers to be added, such as
247
+ 129
---------
The program should then pause while the student works on the problem. When the student is ready to check the answer, he or she can press a key and the program will display the correct solution:
247
+ 129
---------
376
Solution:
# include <iostream>
# include <cstdlib>
# include <ctime>
using namespace std;
int main()
{
srand(time(0)); //srand use to change displaying value each time
int a=rand(); //a declared equal to some random number in range of int
int b=rand(); //b declared equal to some random number in range of int
cout<<"Welcome to Math Tutor"<<endl;
cout<<a<<endl; //a random number displayed
cout<<b<<endl; //b random number displayed
cout<<"Press Enter key to display the Sum of Both Numbers:"<<endl;
cin.get(); //will stop program excecution until enter is pressed 
cout<<a+b<<endl; //sum of a and b random number displayed

system("pause");
return 0;
}

2 comments

Write comments
Anonymous
AUTHOR
3 March 2016 at 02:00 delete This comment has been removed by the author.
avatar
Anonymous
AUTHOR
3 March 2016 at 02:01 delete

Keep up the excellent works guys I’ve included you guys to our blogroll. math tutor

Reply
avatar