Showing posts with label relational and conditional operator. Show all posts
Showing posts with label relational and conditional operator. Show all posts

find a given number is positive or negative number in C without if statement, 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("Positiv e number");
break;
}
default:
{
printf("Negativ e number");
break;
}
}
getch();
}

Labels