Friday, May 31, 2019

Write a C Program to Check Positive or Negative Number

Write a C Program to Check  Positive or Negative Number

Positive Number : If Number is Greater than 0
Negative Number :  If Number is less than 0


Program:

#include<stdio.h>
#include<conio.h>

int main()
{
 int num;
 printf("Enter any number: ");
 scanf("%d", &num);
 if (num > 0)
 {
  printf("%d is a Positive number \n", num);
 }
  else if (num < 0)
  {
   printf("%d is a Negative number \n", num);
  }
  else
  {
   printf("0 is Neither Positive nor Negative");
  }
  getch();
}

Output:

Enter any number: -6
-6 is a Negative number

0 Comments:

Post a Comment