HTML Tutorial || Networking Assignment || Computer Full Forms || Ms-Office Shortcut Keys || Ms-Office Notes || Number System Notes || Internet Assignment
JavaScript Tutorial || CSS Tutorial || Operating System Notes || History of Computer Assignment || Netwoking Notes || Computer Fundamentals Notes

C Program to Check Whether a Number is Positive, Negative or Zero Using Switch Case ?


Q:- Write a C Program to Check Whether a Number is Positive, Negative or Zero
       Using Switch Case ?
       Input
         #include<stdio.h>
         #include<conio.h>
         main()
    {
int num;
clrscr();
printf(“Enter a Number =”);
scanf(“%d”,&num);
switch( num > 0 )
{
case 1: printf(“%d is Positive.”,num);
break;
case 0:
switch ( num < 0 )
{
case 1: printf(“%d is Negative.”,num);
break;
case 1: printf(“%d is Zero.”,num);
break;
default : printf(“Invalid Input!!!!!!!!”);
}
getch()
     }


Output

Enter a Number = -34
-34 is Negative.

Comments