This program is to display the electricity bill calculation based on the number of units consumed every month
Input : the number of units – variable name – unit
Output – Amount of rupee – variable name – amount
Logic:
Units | Rupees |
1-50 units | 0.75/unit |
51-100 | 0.85/unit |
101-200 | 1.50/unit |
201-300 | 2.20/unit |
>300 | 3.00/unit |
In all the cases, there will be service charge of Rs.20 will be collected.
#include <stdio.h>
#include <conio.h>
int main()
{
float amount=0,units;;
printf("Enter the number of units");
scanf("%f", &units);
if(units <=50)
{
amount = units * 0.75;
}
else if(units >50 && units <=100)
{
amount=0.75 * 50 + 0.85*(units-50);
}
else if(units >100 && units <200)
{
amount=(0.75*50) + (0.85*50 )+ (1.5 *(units-100));
}
else if(units >200 && units <300)
{
amount=(0.75*50) + (0.85*50 )+ (1.5 *100) + (2.20 *(units-200));
}
else
{
amount=(0.75*50) + (0.85*50 )+ (1.5 *100) + (2.20 * 100) +(3.0*(units-300));
}
amount=amount+(0.2*amount);
printf("The total electricity bill is %f", amount);
getch();
return 0;
}
thanks really helped
ReplyDeleteplease write few line, it will be easy to understand
ReplyDeletetoo short...please extend it
ReplyDeletei need c code for spot billing machine
ReplyDeletehelps very good...!!!!
ReplyDeleteif th units used is greater than 300 an intrest of 15% wil b given then hw 2 modify ys pgm
ReplyDeleteit gies good ideas"THANK U".good
ReplyDeletedear sir ,
ReplyDeletei wants write a program in c language to print an item (or product) bill with use of item_name, item_price, quantity_of_items,sell_item and total_of_amount.
so i need a help to make this type of program in c language.
thanks.....!
Helps very much yaar...!And could understand it very clearly.Thanks..!
ReplyDelete