Check whether a number is negative, positive or zero
Sample Output
Enter a number: -76 -76 is negative number. Process returned 0 (0x0) execution time : 18.199 s Press any key to continue.
Source Code
#include<stdio.h> int main() { int num1; printf("Enter a number: "); scanf("%d", &num1); if(num1 > 0) { printf("\n%d is positive number.\n", num1); } else if(num1 < 0) { printf("\n%d is negative number.\n", num1); } else if(num1 == 0) { printf("\nZero Detected!\n"); } else { printf("Invalid Input!"); } return 0; }
Sample Output
Enter a number: 333 333 is positive number. Process returned 0 (0x0) execution time : 5.423 s Press any key to continue.
No comments:
Post a Comment