Programiz
programiz.com › c-programming › examples › negative-positive-zero
C Program to Check Whether a Number is Positive or Negative
#include <stdio.h> int main() { double num; printf("Enter a number: "); scanf("%lf", &num); if (num <= 0.0) { if (num == 0.0) printf("You entered 0."); else printf("You entered a negative number."); } else printf("You entered a positive number."); return 0; } You can also solve this problem ...
GeeksforGeeks
geeksforgeeks.org › c language › c-program-to-check-whether-a-number-is-positive-or-negative-or-zero
C Program to Check Whether a Number is Positive or Negative or Zero - GeeksforGeeks
First use if statement for zero, then else if statement of less than zero numbers (negative) and finally if nothing matches, then it is positive numbers. ... // C Program to check if a number is positive, negative, // or zero using simple ...
Published July 11, 2025
Sanfoundry
sanfoundry.com › c-program-integer-positive-or-negative
Positive or Negative Number in C - Sanfoundry
May 13, 2022 - Here is source code of the C program which checks a given integer is positive or negative. The C program is successfully compiled and run on a Linux system. The program output is also shown below. ... 1. Take the integer which you want to check as input and store it in a variable number. 2. Using if,else statements check whether the integer is greater or lesser than zero.
BeginnersBook
beginnersbook.com › 2015 › 02 › c-program-to-check-whether-the-given-integer-is-positive-or-negative
C Program to check whether a given integer is positive or negative
In the following program, we are using if-else statement. If the input number is greater than zero then its a positive number else it is a negative number. If the number is zero then it is neither positive nor negative. #include <stdio.h> void main() { int num; // Prompt user to enter an integer ...
Log2Base2
log2base2.com › c-examples › control › positive-or-negative-in-c.html
C program to check whether the given number is positive or negative.
C programming solution to check whether the given number is positive or negative.
Medium
vigneswaran2510.medium.com › c-program-to-check-whether-a-number-is-positive-or-negative-41ece1d3851f
C program to check whether a number is positive or negative | by VIGNESWARAN.S | Medium
June 6, 2021 - Nested If in C is helpful if you want to check the condition inside a condtion. if the entered number is 0.0,it will print the statement “you entered 0” · In these lines else statement is used.Because if we entered less than 0.0 else statement will print the statement as “you entered a negative number” · Then the second else statement is ,if we didn’t entered 0.0 or less than 0.0 it will print the statement as “you entered a positive number”. return 0 in the main function means that the program executed successfully.
Saralcode
saralcode.com › c-programs › c-program-to-check-whether-a-number-is-positive-or-negative
C Program to Check Whether a Number is Positive or Negative
In this program, we have to take an integer as input from the user using scanf() function and store it in a variable. Then compare the number with 0. ... #include <stdio.h> void main(){ int num; printf("Enter a num: "); scanf("%d", &num); if (num > 0){ printf("Number is positive"); } else if (num < 0){ printf("Number is negative"); } else{ printf("Number is Zero"); } }...
Techcrashcourse
techcrashcourse.com › 2015 › 11 › c-program-check-number-positive-negative-zero.html
C Program to Check Whether a Number is Positive, Negative or Zero
Then we check whether input number is positive, negative or zero using if else ladder statement. ... #include <stdio.h> int main() { int number; printf("Enter a Number\n"); scanf("%d", &number); if(number > 0) { printf("%d is Positive Number", number); } else if (number < 0) { printf("%d is ...
IncludeHelp
includehelp.com › c-programs › c-program-to-check-number-is-positive-negative-or-zero-using-loop.aspx
C program to check whether number is POSITIVE, NEGATIVE or ZERO
/* C program to check whether number ... int num; char choice; do { printf("Enter an integer number :"); scanf("%d", &num); if (num == 0) printf("Number is ZERO."); else if (num > 0) printf("Number is POSITIVE."); else printf("Number is NEGATIVE."); printf("\n\nWant to check again ...
Sankalandtech
sankalandtech.com › Tutorials › C › c-positive-negative.html
C Program to check entered number is ZERO, POSITIVE or NEGATIVE until user does not want to quit. using while do while loop
/* C Program to check entered number is ZERO, POSITIVE or NEGATIVE until user does not want to quit. using while loop */ #include <stdio.h> /* C program to check whether number is POSITIVE, NEGATIVE or ZERO until user doesn’t want to exit.*/ int main() { int n; char choice; printf("\n\nWant to check POSITIVE/NEGATIVE Number (press Y/y for 'yes') :"); fflush(stdin); scanf(" %c", &choice); while (choice == 'Y' || choice == 'y') { printf("Enter any number number :"); scanf("%d", &n); if (n > 0) printf("\n %d is POSITIVE Number .",n); else if (n == 0) printf("Number is ZERO."); else printf("\n %d is NEGATIVE Number .",n); printf("\n\nWant to continue again (press Y/y for 'yes') :"); fflush(stdin); /*to clear input buffer*/ scanf(" %c", &choice); /*Here is a space before %c*/ } printf("\nBye Bye!!!"); return 0; }
WsCube Tech
wscubetech.com › resources › c-programming › programs › positive-negative
C Program to Check Positive or Negative Number (4 Ways)
August 29, 2025 - Learn 4 different ways to check if a number is positive or negative in C programming. Explore various methods to handle number comparisons.
Codeforwin
codeforwin.org › home › c program to check positive negative or zero using switch case
C program to check positive negative or zero using switch case - Codeforwin
July 20, 2025 - So first let us define expressions to check positive, negative or zero. (num > 0) return 1 (true) for positive number, otherwise 0 (false). (num < 0) check negative and return 1 for negative number, otherwise 0.