Publish Your Code, Article For Free​.

Table of Contents

Write a C program to find Number is positive or Negative

Prabhu

Prabhu

Table of Contents

The following concept will test whether a number is positive or negative using C Programming. It is done by checking where the number lies on the number line.

The following algorithm will help to check this condition.

  • If the input number is greater than zero then it is a positive number.
  • If the input number is less than zero it is a negative number.
  • If the number is zero then it is neither positive nor negative.

Working

  • Step 1. Start
  • Step 2. Enter the number

C Programme

 #include<stdio.h>
     int main()
     {
     int num;
     printf("Insert a number:");
     scanf("%d", &num);
     //Condition to check if the number is negative or positive
     if (num <= 0)
     {
     if (num == 0)
        printf("The number is 0.");
     else
        printf("The number is negative");
     }
     else
        printf("The number is positive");
     return 0;
     }
Output:
Insert a number:56                                                                                                                                                                                                         
The number is positive

Publish Your Code, Article For Free​.

you're currently offline