‘C’ program to accept a number and check if it is positive, negative or zero.

C File =>


/* Write a ‘C’ program to accept a number and check if it is positive, negative or
 zero. */

#include<stdio.h>
int main() 
{
     int num;
     printf("\n Enter an integer : ");
     scanf("%d",&num);
 
    if(num==0)
          printf("\n Number is Zero");
   else if(num>0)
          printf("\n Number is positive");
   else if(num<0)
          printf("\n Number is negative");
 return 0;
}

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.