C语言函数之加减乘除
#include<stdio.h>
int main()
{
float jia(float x,float y);
float jian(float x,float y);
float cheng(float x,float y);
float chu(float x,float y);
float a,b;
printf("请输入两个数:\n");
scanf("%f%f",&a,&b);
printf("%f+%f=%f\n",a,b,jia(a,b));
printf("%f-%f=%f\n",a,b,jian(a,b));
printf("%f*%f=%f\n",a,b,cheng(a,b));
printf("%f/%f=%f\n",a,b,chu(a,b));
}
float jia(float x,float y)
{
float k;
k=x+y;
return k;
}
float jian(float x,float y)
{
float i;
i=x-y;
return i;
}
float cheng(float x,float y)
{
float j;
j=x*y;
return j;
}
float chu(float x,float y)
{
float l;
l=x/y;
return l;
}
|
|