For any integer n, the definition of a sign function sign (n) as follows:
Write a program to calculate a function of the input value of any integer.
Input format:
input integer n in the given row.
Output format:
the output function value corresponding to the integer n in the format "sign (n) = function value" in a row.
Input Example 1:
10
Sample Output. 1:
Sign (10). 1 =
Input Sample 2:
0
Output Sample 2:
Sign (0) = 0
Input Sample 3:
-98
Sample Output. 3:
Sign (-98) = -1
#include<stdio.h>
int main()
{
int n,x;
scanf("%d",&n);
if (n<0)
x=-1;
else if (n==0)
x=0;
else
x=1;
printf("sign(%d) = %d",n,x);
return 0;
}