Program to find that the given number is positive or negative number in C without using if statement (use relational and conditional operator)

Program to find that the given number is positive or negative number in C without using if statement (use relational and conditional operator)

# include <math.h>
# include <stdio.h>
# include <conio.h>

void main()
{
            clrscr();
            int p,n;
            printf("Enter two no=");
            scanf("%d",&amp;p);
            switch(n=abs(p) +(-p))
            {
                        case 0:
                        {
                                    printf("Positive number");
                                    break;
                        }
                        default:
                        {
                                    printf("Negative number");
                                    break;
                        }
            }
            getch();
}


Post a Comment