Total Bill with discount using Ternary Operators

TOTAL BILL/ DISCOUNT A

WAP to find out Total Bill with discount according to conditions (Ternary Operators)
void main ()
{
int b,dis,n;
clrscr ();
printf ("Enter Bill: ");
scanf ("%d",&b);
dis=(b<500)?(b*.10):(b>=500 &&amp; b<1000)?(b*.15):(b>=1000 && b<=2000)?(b*.20):(b*.25);
n=b-dis;
printf ("Net Bill is %d",n);
getch();
}

No comments:

Post a Comment