c-programs-basics
In this c program, we will get any random number from the user and check whether the number is positive or negative. The logic behind this is simple.
We get a number from the user using scanf function in c, check whether the number is greater than 0 or not. If the number turns out to be greater than zero we print the message as this number is positive or else the number is negative. 
To perform this type of program we use conditional statement if...else..
The general format of If..Else...statement
if(condition = true)
  {
       // perform this statements
  } 
else
{
      //perform this statements
}

C program to check the number is positive or negative using if..else..statement 

#include<stdio.h>
#include<conio.h>
void main()
{
 int n;
 clrscr();

 printf("\n Enter Any Number : ");
 scanf("%d",&n);

 if(n>=0)
 {
  if(n==0)
   {
    printf("\n Number is Zero ");
   }
   else
   {
    printf("\n %d is Positive ",n);
   }
 }
 else
 {
  printf("\n %d is Negative ",n);
 }

 getch();
}

Output:
positive-negative-c-program-output

positive-negative-c-program-output

positive-negative-c-program-output







Positive or Negative - C Program for Dev C++

#include<stdio.h>
int main()
{
 int n;
 
 printf("\n Enter Any Number : ");
 scanf("%d",&n);

 if(n>=0)
 {
  if(n==0)
   {
    printf("\n Number is Zero ");
   }
   else
   {
    printf("\n %d is Positive ",n);
   }
 }
 else
 {
  printf("\n %d is Negative ",n);
 }

 getch();
 return 0;
}

Output:
positive-negative-c-program-output

positive-negative-c-program-output

positive-negative-c-program-output






In this way, we can perform the program to check whether the given number is positive or negative.