C Reference function abs()

This function of stdlib will return the absolute value of an integer.

Usage of abs():

int abs ( int x );

Parameters:

An integer x.

Return value:

The absolute value of integer x.

Source code example of abs():


	#include<stdio.h>
	#include<stdlib.h>

	int main ()
	{
		int x;

		x=abs(-17);
		printf ("x=%d\n",x);
		return 0;
	}

Output of the abs example program above:


	x=17

This entry was posted in C Reference stdlib.h Functions. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed. Tweet This! Tweet This! or use to share this post with others.

Comments are closed.