计算机在教育中的作用越来越大。编写一个程序,帮助小学生学习乘法。用rand函数产生两个包含一个数字的整数(即:0~9之间的整数),然后显示下面的问题:How much is 6 times 7?学生然后键入答案,程序接着检查学生输入的答案。如果答案正确,程序打印出“very good!”,如果答案不正确,程序打印出“No!” 。
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(void)
{
int a,b,yournumber,daan;
srand(time(0)); a=rand()%10;
b=rand()%10;
printf("%d*%d\n",a,b);
printf("How much is 6 times 7?\n");
scanf("%d",&yournumber) ;
daan=a*b;
if(daan==yournumber)
{
printf("very good!\n");
}
else
printf("No!\n");
return 0;
}