c语言:在主函数中输入一个整形数据,调用子函数求其绝对值,并在主函数中输出
来源:百度知道 编辑:UC知道 时间:2024/05/17 08:41:55
c语言
#include"stdio.h"
int fabs1(int x)
{
if(x<0)return -x;
else return x;
}
main()
{
int n;
scanf("%d",&n);
printf("%d",fabs1(n));
}
#include<stdio.h>
void fab(int temp)
{(temp>0)?printf("%d",temp):printf("%d",-temp);}
void main()
{
printf("enter the number:");
int temp=0;
scanf("%d",&temp);
fab(temp);
}