-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProg67.c
More file actions
34 lines (29 loc) · 711 Bytes
/
Prog67.c
File metadata and controls
34 lines (29 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// C-program to input electricity unit charges and calculate total electricity bill according to the question.
#include <stdio.h>
int main()
{
int unit;
float amt, totalamount, surcharge;
printf("Enter total units consumed: ");
scanf("%d", &unit);
if(unit <= 50)
{
amt = unit * 0.50;
}
else if(unit <= 150)
{
amt = 25 + ((unit-50) * 0.75);
}
else if(unit <= 250)
{
amt = 100 + ((unit-150) * 1.20);
}
else
{
amt = 220 + ((unit-250) * 1.50);
}
surcharge = amt * 0.20;
totalamount = amt + surcharge;
printf("Electricity Bill = Rs. %.2f", totalamount);
return 0;
}