Write a program that inputs a number from user and determines whether its Positive, Negative or Zero
Input:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include <stdio.h> #include <conio.h> void main (void) { int num; printf("Enter a number: "); scanf("%d", &num); if (num>0) printf("The number is Positive"); if(num<0) printf("The number is negative"); if(num==0) printf("The number is zero"); getch(); } |
Output:
Case1:
Enter an integer Number: 9
The number is positive
Case2:
Enter an integer Number: -45
The number is negative
Case3:
Enter an integer Number: 0
The number is zero
No comments:
Post a Comment