An Electricity Board charges for electricity per month from their consumers according to the units consumed. The tariff is given below:
Units consumed
Cges
Up to 200 units
Rs.3.80/unit
More than 200 units and up to 300 units
Rs.4.40/unit
More than 300 units and up to 400 units
Rs.5.10/unit
More than 400 units
Rs.5.80/unit
Write a program to calculate the electricity bill taking consumer’s name and units consumed as inputs. Display the output.
Answers
Program to calculate the electricity bill taking consumer’s name and units consumed as inputs.
Explanation:
A program in C to calculate and print the Electricity bill of a given customer.
#include <stdio.h>
#include <string.h>
int main()
{
float chg, unit,consume;
char cust_name[25];
printf("Input the name of the customer :");
scanf("%s", cust_name);
printf("Input the unit consumed by the customer : ");
scanf("%f",&unit);
if (unit <200 )
chg = 3.80;
else if (unit>=200 && unit<=300)
chg = 4.40;
else if (unit>300 && unit<=400)
chg = 5.10;
else
chg = 5.80;
consume = unit*chg;
printf("\nElectricity Bill\n");
printf("Customer Name : %s\n",cust_name);
printf("unit Consumed : %.3f\n",consume);
return 0;
}
Output
Input the name of the customer :Simran
Input the unit consumed by the customer : 350
Electricity Bill Customer Name : Simran
unit Consumed : 1785.000
Answer:
c_4/g-6
taking in progress
Explanation:
68*123