"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Wednesday, April 7, 2010

Computers are playing an increasing role in education. Write a program that will help elementary school students to learn multiplication. Use rand to produce two positive one-digit integers. Your program should ask a question such as : 'How much is 6 times 7 ?' The student then type the answer. Your program checks the student's answer. If correct, print "Very Good!" and then ask another question. If the answer is wrong, print "No, Please Try Again." And then let the student try the same problem again until correct response is received.


#include<iostream.h>
#include<conio.h>
#include<Time.h>
#include<stdlib.h>

const int Limit = 9;

void main()
{
int n1, n2, pro = 1, ans = 0 ;

char ch = 'y';

cout << "\n ******* LEARN MULTIPLICATION ********* \n\n ";

while(ch=='y' || ch == 'Y')
{

randomize();
n1 = random(Limit);
randomize();
n2 = random(Limit);
pro = n1 * n2;

while(pro != ans )
{
cout << "\n How much is " << n1 << "times" << n2 << "?" ;
cout << "\n Enter your answer : ";
cin >> ans;
if(pro == ans )
     cout << "\n Very Good!!!!";
else
      cout<< "No, Please Try again .";
}
pro = 1;
ans = 0;
cout << " Do you continue (Y/N)? ";
cin >> ch;

}

getch();
}

No comments:

Post a Comment

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.