例求一个数的绝对值 /*ch41.c*/ #include <stdio.h> main( int x,y, printf("Enter an integer:") scanf("%d",&x); y-X; if(y0) y=-y; printf("\ninteger:%d->absolute value:%d n",x,y); 运行: Enter an integer:-12. integer:-12->absolute value 12/*ch4_1.c*/ #include <stdio.h> main() { int x,y; printf("Enter an integer:"); scanf("%d" ,&x); y=x; if(y<0) y= -y; printf("\ninteger:%d->absolute value:%d\n" ,x,y); } 例 求一个数的绝对值 运行:Enter an integer:-12 integer:-12->absolute value :12