C examples for Statement:if
Implement the sign function.
#include <stdio.h> int main (void) { int number, sign; printf ("Please type in a number: "); scanf ("%i", &number); if (number < 0) sign = -1;//from w w w . jav a 2s . com else if (number == 0) sign = 0; else sign = 1; printf ("Sign = %i\n", sign); return 0; }