Function abs () in C

The function int abs (int x) returns the absolute value of integer x.

Function abs () in C

The function int abs (int x) returns the absolute value of integer x .

Declare the function abs () in C

Here is the declaration section for abs () in C:

 int abs ( int x ) 

Parameters

x : this is an integer value.

Returns the value

Returns the absolute value of x.

For example

The following C program illustrates the usage of abs () in C:

 #include #include int main () { int a , b ; a = abs ( 6 ); printf ( "Gia tri cua a = %dn" , a ); b = abs (- 11 ); printf ( "Gia tri cua b = %dn" , b ); return ( 0 ); } 

Compiling and running the above C program will produce the following results:

Picture 1 of Function abs () in C

According to Tutorialspoint

Previous lesson: qsort () function in C

Next lesson: Div () function in C

Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile