C abs function

The C abs function is one of the Math methods used to return the absolute positive value of a given number. The syntax of the abs is as shown below.

int abs(int number);

C abs Function Example

The C math abs Function allows you to return the absolute positive integer of a user given number. In this program, We are going to find the same and display the output.

#include <stdio.h>
#include <math.h>

int main()
{
    printf("\n The Absolute Positive Value of 75    = %d ", abs(75));
    printf("\n The Absolute Positive Value of -15   = %d ", abs(15));
    printf("\n The Absolute Positive Value of -152  = %d ", abs(152));
    
    printf("\n The Absolute Positive Value of -14  = %d ", abs(-14));
    printf("\n The Absolute Positive Value of -26  = %d ", abs(-26));
    printf("\n The Absolute Positive Value of 90  = %d \n", abs(90));
    
    return 0;
}
C abs function to find the absolute positive value example

abs Example 2

In this C Programming example, we are allowing the user to enter their value. Next, we this program uses the abs math function to find the absolute positive number.

#include <stdio.h>
#include <math.h> 

int main()
{
    int number;
    
    printf(" Please Enter any Numeric Value :  ");
    scanf("%d", &number);
    
    printf("\n The Absolute Positive Value of %d = %d \n", number, abs(number));
    
    return 0;
}
 Please Enter any Numeric Value :  -987

  The Absolute Positive Value of -987 = 987