我想请教大家一道C语言的题目

来源:百度知道 编辑:UC知道 时间:2024/05/24 20:35:20
通过输入两个加数给学生出一道加法运算题,如果输入答案正确,则显示“Right!”,否则显示“Not correct! Try again!”。
具体要求:
①计算两整型数之和
②所有变量定义为整数变量。
③键盘输入数据前要有提示。
④要求用函数对学生输入的答案进行判断。

#include<stdio.h>
int main()
{
int a,b,sum,temp,i,n;
printf("输入两整数:");
scanf("%d%d",&a,&b);
printf("%d + %d = ",a,b);
do
{
scanf("%d",&n);
if(n==a+b)printf("Right!\n");
else printf("Not correct! Try again!\n");
}
while(n!=a+b);
return 0;
}

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
main()
{int a,b,c,d=1;
while(d!=0)
{srand(time(0));
a=random(100);
b=random(100);
printf("%d+%d=",a,b);
scanf("%d",&c);
if((a+b)==c)
printf("Very Good\n");
else
printf("Sorry your are error\n");
scanf("%d",&d);
}
}

#include "stdio.h"
void main()
{

int dicide (int ,int ,int ) ;

int num1,num2,sum;

printf("input first