Program to Find the absolute value of an integer taken as input.



/* Find the absolute value of an integer taken as input. */

#include

int main(void)
{
int num;

printf("\nEnter a number : ");
scanf("%d" ,&num);

if(num < 0)
{
printf("\nAbsolute value of %d is %d" ,num ,-num);
}
else
{
printf("\nAbsolute value of %d is %d" ,num ,num);
}


return 0;
}

1 comment: