Friday, May 4, 2018

C-Program to find the absolute value of a number entered through the keyboard.



Absolute value of a number : Absolute value describes the distance of a number on the number line from 0 without considering which direction from zero the number lies. The absolute value of a number is never negative. The absolute value of 5 is 5.

CProgram : 



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

int main()
{
int num;
float num_r;

printf("Enter the number : ");
scanf("%f",&num_r);

num=abs(num_r);
printf("Absolute Value Is %d",num);
getch();
return 0;
}




OUTPUT : 


Enter the number : -9
Absolute Value Is 9

Enter the number : 5.8
Absolute Value Is 6

Enter the number : 5.4
Absolute Value Is 5

0 comments: