Check if a Number is Positive or Negative C Program

By | July 4, 2017

Let us learn how to check if a number is positive, negative or zero and implement a C program to check if a number is positive or negative using Arrays, For and If Else Loop.

Positive and Negative Numbers

To check whether an integer is negative or positive, we need to compare it with zero essentially.

Here’s the number line that will help you do the comparison and find whether the number is less or greater than zero.

Number Line To Find if a Number is Positive or Negative or Zero

TutorVista

Algorithm To Find Whether A Number Is Positive Or Negative

  1. Input a number from the user
  2. If number is less than zero, then it is a negative integer
  3. Else If number is greater than zero, then it is a positive integer
  4. Else, the number is equal to zero
  5. End

Note: This code to find whether an integer is positive or negative in C programming is compiled with GNU GCC compiler on CodeLite IDE. However, these codes are compatible with all other operating systems.

Must Read: C Program To Find Quotient of a Number

C Program To Check If A Number Is Positive Or Negative

Must Read: C Program For Age Calculator

Output

Check If A Number is Positive or Negative in C Programming using If Else Loop

Must Read: C Program To Print Pascal Triangle

 

Method 2: C Program To Find Positive Or Negative Number In Array

Must Read: C Program To Display Digital Clock

 

Output

c program to find positive or negative number in array using For Loop

Let’s discuss more on this C program to check if a number is positive or negative or zero in the comment section below. Also, let us know if you have any compilation errors and any doubts about the same.

Let's Discuss