求c语言大神指导 第二题!Write a program that would be used to teach multiplication to children.Your program should first ask the user to enter two numbers (A and B).Then it would ask the user to enter the result of A x B (i.e.product of A an

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/13 01:27:34
求c语言大神指导 第二题!Write a program that would be used to teach multiplication to children.Your program should first ask the user to enter two numbers (A and B).Then it would ask the user to enter the result of A x B (i.e.product of A an

求c语言大神指导 第二题!Write a program that would be used to teach multiplication to children.Your program should first ask the user to enter two numbers (A and B).Then it would ask the user to enter the result of A x B (i.e.product of A an
求c语言大神指导 第二题!
Write a program that would be used to teach multiplication to children.Your program should first ask the user to enter two numbers (A and B).Then it would ask the user to enter the result of A x B (i.e.product of A and B).If the user gets it right,then the program asks the user if he/she wants to play again.If yes,then again start by entering two new numbers for A and B.If no,then end the program.
However,if the user inputs an incorrect result for A x B your program will give them two more chances to get it right.If they fail three times,then start again by asking them to enter two new numbers for A and B.

求c语言大神指导 第二题!Write a program that would be used to teach multiplication to children.Your program should first ask the user to enter two numbers (A and B).Then it would ask the user to enter the result of A x B (i.e.product of A an
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
int a,b,ans;
int count=0;
char ch;
while(1)
{
printf("please input num A and num B:");
scanf("%d %d",&a,&b);
fflush(stdin);
printf("please input the ans of A*B:");
LABLE:scanf("%d",&ans);
fflush(stdin);
if(a*b==ans)
{
printf("do you want to play again?please input y for yes,n for no:");
scanf("%c",&ch);
fflush(stdin);
if(ch=='y')
{
count=0;
continue;
}
else if(ch=='n')
{
break;
}
}
else
{
count++;
if(count<3)
{
printf("your answer is wrong,please reInput your answer:");
goto LABLE;
}
else
{
printf("You have already answered incorrectly three times, calculate the next question.\n");
continue;
}
}
}


system("PAUSE");
return 0;
}