Wednesday, 10 August 2011

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

No comments:

Post a Comment