B
beg_c++
hi i am a beginner in c++, i have a project to be done by few weeks.
This project is a maths help for kids!! it is supposed to ask the kid
how many problems the kid want and then show the problems and then the
kid has to answer it and then the program says if is right or wrong!!
i have half done by my self!!! i cant figure out one thing!! how do i
do for the program give the exactly number of problems that the kid
asked for!!! i have got the idea for that i am basically sure it is a
loop but i cant set it up!! Can someone help me?
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int number, answer; //variables
cout<<"how many problems would like?"; //display the question
cin>>number;
srand(time(NULL));
int j=1+(int) (12.0*rand()/(RAND_MAX+1.0)); // generate first
random number
int j1=1+(int) (12.0*rand()/(RAND_MAX+1.0)); // generate second
random number
cout<<"Question 1: What is "<<j<<" x "<<j1<<"?";// first question
cin>>answer;
if (answer==j*j1) //anser correct or
wrong
cout<<"Correct!"<<endl;
else
cout<<"No,"<<j<<" x "<<j1<<" is: "<<j*j1<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
This project is a maths help for kids!! it is supposed to ask the kid
how many problems the kid want and then show the problems and then the
kid has to answer it and then the program says if is right or wrong!!
i have half done by my self!!! i cant figure out one thing!! how do i
do for the program give the exactly number of problems that the kid
asked for!!! i have got the idea for that i am basically sure it is a
loop but i cant set it up!! Can someone help me?
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int number, answer; //variables
cout<<"how many problems would like?"; //display the question
cin>>number;
srand(time(NULL));
int j=1+(int) (12.0*rand()/(RAND_MAX+1.0)); // generate first
random number
int j1=1+(int) (12.0*rand()/(RAND_MAX+1.0)); // generate second
random number
cout<<"Question 1: What is "<<j<<" x "<<j1<<"?";// first question
cin>>answer;
if (answer==j*j1) //anser correct or
wrong
cout<<"Correct!"<<endl;
else
cout<<"No,"<<j<<" x "<<j1<<" is: "<<j*j1<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}