Sep 27, 2018 at 12:56am UTC
guys this is my programme
but im recieving some errors . can someone help me please
#include<iostream>
void generatequestion(int op,int num1 ,int num2)
{
switch(op)
{
case 0:
cout<<"\nHow much is "<<num1<<" + "<<num2<<"?";
break;
case 1:
cout<<"\nHow much is "<<num1<<" - "<<num2<<"?";
break;
case 2:
cout<<"\nHow much is "<<num1<<" * "<<num2<<"?";
break;
case 3:
cout<<"\nHow much is "<<num1<<" / "<<num2<<"?";
break;
}
}
int main()
{
clrscr();
int num1 , num2 , op , m;
float ans;
char messagecorrect[4][30] = {"Very Good!","Excellent!","Nice Work","Keep up the good work"};
char messagewrong[4][30] = {"No . Please try again ." , "Wrong . Try once more ." , "Dont give up!" , "No. Keep trying"};
while(ans!=1)
{
srand (time(NULL));
num1 = rand() % 10;
num2 = rand() % 10;
op = rand() % 4;
label1:
m = rand() % 4;
generatequestion(op,num1,num2);
cin>>ans;
if(op==0 && ans==(num1+num2))
cout<<messagecorrect[m];
else if(op==1 && ans==(num1-num2))
cout<<messagecorrect[m];
else if(op==2 && ans==(num1*num2))
cout<<messagecorrect[m];
else if(op==3 && ans==(num1/num2))
cout<<messagecorrect[m];
else
{
cout<<messagewrong[m];
if(ans!=1)
goto label1;
}
}
return 0;
}