<b>一、程序代码</b>
# /* Name abs.c
# * Author dyli
# * date 20110711
# * Description deepen understand the math
* function of abs()
# *
# * */
# /***abs()函数************************************************
# * 函数功能: 取一个数的绝对值
# * 函数原型:
# * 返回值 : 绝对值
# * 所需库 : math.h
# * 备注 :
# ****************************************************************/
#include stdio.h>
#include math.h>
int main(void)
{
int nega_value = 0;
int posi_value = 0;
printf("please input a Negative number(fu shu)\n");
scanf("%d",&nega_value);
posi_value = abs(nega_value);
printf("---------->output the absolute value\n\---------->and it must be positive \n");
printf("look here %d \n",posi_value);
return 0;
}
<b>二、运行效果</b>
[root@localhost abc]# ls
abs abs.c abs.c~ fopen.txt Makefile
[root@localhost abc]# ./abs
please input a Negative number(fu shu)
-9632
---------->output the absolute value
---------->and it must be positive
look here 9632
[root@localhost abc]#