Write a C program to absolute value of a number given by the user.

#include<stdio.h>
main()
{
     int a,abs;
     printf("\nEnter a number=");
     scanf("%d",&a);
     if(a<0)
          abs=a*(-1);
     else
          abs=a;
     printf("\nThe absolute value of %d is %d",a,abs);
}

No comments:

Post a Comment