1.

If else if ladder example to check if a number is greater or smaller than zero​

Answer»

Answer:

below program is similar to your question.

smaller than zero means negative, greater than zero means positive.

Explanation:

C program to check negative, zero or positive.

*/

#INCLUDE

int main()

{

/* Declare INTEGER variable */

int num;

/* Input an integer from user */

PRINTF("ENTER any number: ");

scanf("%d", &num);

if(num < 0)

{

/* If number is less than zero, then it is negative */

printf("NUMBER IS NEGATIVE.");

}

else if(num == 0)

{

/* If number equal to 0, then it is zero */

printf("NUMBER IS ZERO.");

}

else

{

/* If number is greater then zero, then it is positive */

printf("NUMBER IS POSITIVE.");

}

return 0;

}

Output of the above program.

Enter any number: -22

NUMBER IS NEGATIVE.



Discussion

No Comment Found