作业1:
通过输入两个加数,给学生出一道加法运算题。如果输入答案正确,则显示“Y”;否则显示“N”。
要求:程序循环执行n次,用函数实现判断对错和输出结果
我的程序:
#include<stdio.h>
double p(double a,double b)
{
double x;
x=a+b;
return (x);
}
void main()
{
double c,d,e;
for(; ;){
printf ("put two number\n");
scanf("%lf%lf",&c,&d);
printf("%lf+%lf=\n",c,d);
scanf("%lf",&e);
if(e==p(c,d))
printf("y\n");
else
printf("n\n");}
}
运行结果: