C program to check a given number is positive or negative





C program to check a given number is positive or negative


#include<stdio.h>
int main(){
    int num;
    scanf("%d",&num);
   
    if(num ==0)
         printf("Number is zero.");
    else if(num > 0)
printf("Number is positive.");
else
printf("Number is negative.");
    return 0;
}


Algorithm:


A number greater than zero is called positive number while a number less than zero is called negative number. Zero is neither positive number nor negative number it at the boundary of positive number and negative number.


No comments:

Post a Comment