let x be the number of units consumed
and y be the number of days
and p be the electricity bill
Required codes are-
#include<stdio.h>
main()
{int x,y,p;
printf("please enter the number of consumed units and number of days consumed");
scanf("%d%d",&x,&y);
if(x"\\le" 200)
{p=2"\\times" x;
}
if(x"\\ge" 200&&x"\\le" 400)
{p=200"\\times" 2+(x-200)"\\times" 4;
}
if(x"\\ge" 400)
{p=4"\\times" x;
}
if(y"\\le" 15)
printf("price is %d",p);
else
{"p=p+\\frac{p}{10};" ;
printf("price is %d",p);
}
}
Comments
Leave a comment