int abs(int n); long labs(long n);
Parameter:
n: đầu vào
Remark:
Hàm abs( ) (labs()) trả về trị tuyệt đối của n.
Ví dụ:
#include "stdio.h" #include "conio.h" #include "stdlib.h" void main() { int x = -123; long y = -134L; printf("abs(%d) = %d", x, abs(x)); printf("\nlabs(%d) = %d", y, labs(y)); getch(); }
Kết quả:
Leave a Reply
You must be logged in to post a comment.