Header file:
stdlib.h
Synopsis:
long int labs(long int num)
Description:
It returns the absolute value of its long integer argument num.
labs function C example:
#include<stdio.h>
#include<stdlib.h>
int main() {
long no;
printf("Enter a number:");
scanf("%ld", &no);
no = abs(no);
printf("Output: %ld\n", no);
return 0;
}
#include<stdlib.h>
int main() {
long no;
printf("Enter a number:");
scanf("%ld", &no);
no = abs(no);
printf("Output: %ld\n", no);
return 0;
}
Output:
jp@jp-VirtualBox:~/$ ./a.out
Enter a number:-234324324
Output: 234324324
Enter a number:-234324324
Output: 234324324
No comments:
Post a Comment