Wednesday, 10 August 2011

how 2 find a given number is positive or negative number in C without using relational and conditional operator


‎# include<stdio.h>
# include<conio.h>
# include<math.h>
void main()
{
clrscr();
int p,n;
printf("Enter two no=");
scanf("%d",&p);
switch(n=abs(p)+(-p))
{
case 0:
{
printf("Positive number");
break;
}
default:
{
printf("Negative number");
break;
}
}
getch();
}

No comments:

Post a Comment