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();
}


Post a Comment