Header Ad

C program to return only absolute values

In this tutorial, we are going to write a C program to return only absolute values like the abs() function in C Programming with practical program code and step-by-step full complete explanation.

C program to return only absolute values


C program to return only absolute values.

 
#include<stdio.h>
#include<conio.h>

void main()
{
    int uabs(int),x;

    printf("Enter a negative value: ");
    scanf("%d",&x);

    x=uabs(x);

    printf("X=%d",x);

}

int uabs(int y)
{
    if(y<0)
        return(y*-1);
    else
        return(y);
}


Output

 
Enter a negative value: -5
X=5


Post a Comment

0 Comments