在C语言中,可以使用 `
以下是使用 `abs` 和 `fabs` 函数的示例代码:
```c
include
include
include
int main() {
// 对于整数
int i = -5;
int abs_i = abs(i); // 返回绝对值
printf("The absolute value of %d is %dn", i, abs_i);
// 对于浮点数
float f = -3.5f;
float abs_f = fabs(f); // 返回绝对值
printf("The absolute value of %f is %fn", f, abs_f);
return 0;