Wednesday, August 10, 2011

C Program find Positive Negative with Switch Case Without Conditional Operator


write a program in c to check whether the given num is Positive or negative using switch case without conditional operator

 ‎#include<stdio.h>
#include<conio.h>
void main(void)
{
char num;
clrscr();
printf("Enter a number +ve or -ve : ");
scanf("%c",&num);
switch(num)
{
case '-':
printf("Negative number");
break;
default:
printf("Positive number");
}
getch();
}

No comments:

Post a Comment