在C语言中,可以使用函数abs()来表示一个数的绝对值。
示例代码:
#include <stdio.h>#include <stdlib.h>int main() { int num = -5; int absNum = abs(num); printf("The absolute value of %d is %d\n", num, absNum); return 0;}输出结果:
The absolute value of -5 is 5
在C语言中,可以使用函数abs()来表示一个数的绝对值。
示例代码:
#include <stdio.h>#include <stdlib.h>int main() { int num = -5; int absNum = abs(num); printf("The absolute value of %d is %d\n", num, absNum); return 0;}输出结果:
The absolute value of -5 is 5