Showing posts with label Positive or Negative Number in C. Show all posts
Showing posts with label Positive or Negative Number in C. Show all posts

Friday, July 24, 2020

Write a Program to check whether the given integer is positive or negative in C.

Positive or Negative Number in C


#include <stdio.h>

int main()

{

    int n;

 

    printf("Enter a Number :: \n");

    scanf("%d", &n);

    if (n > 0)

        printf("%d is a Positive number \n", n);

    else if (n < 0)

        printf("%d is a Negative number \n", n);

}



OUTPUT

Enter a Number :: 
5
5 is a Positive number 

Enter a Number :: 
-5
-5 is a Negative number