C语言编程: 编写计算并显示两个数只差的绝对值,使用调用函数方法编程,主函数调用语句:c=fun(

C语言编程:
编写计算并显示两个数只差的绝对值,使用调用函数方法编程,主函数调用语句:c=fun(a,b);,已知int a,b,c;,编写被调用的函数fun。

#include <stdio.h>
int fun(int a,int b){
return a>b?a-b:b-a;
}
int main(){
int a,b,c;
a=3;b=4;c=fun(a,b);
printf("%d与%d的差的绝对值是%d\n",a,b,c);
a=-3;b=-9;c=fun(a,b);
printf("%d与%d的差的绝对值是%d\n",a,b,c);
}

温馨提示:答案为网友推荐,仅供参考
相似回答