C Online Compiler
Example: Check if a Number is Positive or Negative in C
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Check if a Number is Positive or Negative in C #include <stdio.h> // It's the main function of the program int main() { double number; // Step-1 Take input from user printf("Enter a Number: "); scanf("%lf", &number); printf("Output :: "); // Step-2 Check if the number is negative if (number < 0.0) { printf("NEGATIVE NUMBER\n"); } // Step-3 Check if the number is positive else if (number > 0.0) { printf("POSITIVE NUMBER\n"); } // Step-4 If the previous didn't match then else { printf("You enetered 0\n"); } return 0; }
5.8
Output
Clear
ADVERTISEMENTS