Write a program in C to find out Total Bill with discount according to conditions (Ternary Operators)
#include <stdio.h>
void main ()
{
int b,dis,n;
clrscr ();
printf ("Enter Bill: ");
scanf ("%d",&b);
dis=(b<500)?(b*.10):(b>=500 && b<1000)?(b*.15):(b>=1000 && b<=2000)?(b*.20):(b*.25);
n=b-dis;
printf ("Net Bill is %d",n);
getch();
}
Post a Comment