Use of abs() function in c.

Use of abs function c :-

                                       abs() is a predefine function present in stdlib.h header file in c. It gives always positive value of a number.

Example:-

              abs(-4)=4
               abs(4)=4
              abs(-89)=89

program:-

 #include<stdio.h>
#include<stdlib.h>
int main()
{
    int num,new_num;
    printf(“Enter a numbern“);
    scanf(“%d”,&num);
    new_num=abs(num);
    printf(“New number is %d“,new_num);
    return(0);

input:-

Enter a number
 -98                  

output:-

 New number is 98

2 thoughts on “Use of abs() function in c.

Leave a Reply

Your email address will not be published.