ad

Wednesday, 12 October 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 the 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