0% found this document useful (0 votes)
7 views

Lab 3

Uploaded by

B Vijetha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Lab 3

Uploaded by

B Vijetha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

3.

An electricity board charges the following rates for the use of electricity:
for the first 200 units 80 paise per unit: for the next 100 units 90 paise per
unit: beyond 300 units Rs 1 per unit. All users are charged a minimum of
Rs.100 as meter charge. If the total amount is more than Rs 400, then an
additional surcharge of 15% of total amount is charged. Write a program to
read the name of the user, number of units consumed and print out the
charges.

#include <stdio.h>

int main()

char name[10];

int unit;

float billAmount;

printf("Enter the customer name: \n");

scanf("%s",name);

printf("Enter the total units consumed:\n");

scanf("%d", &unit);

billAmount = 100;

if(unit<=200) {

billAmount= billAmount+(unit*.80);

else if(unit>200 && unit<=300){

billAmount= billAmount+(200*0.80)+((unit-200)*0.90);

else if(unit > 300){

billAmount= billAmount+(200*0.80)+(100*0.90)+((unit-300)*1);

if(billAmount>400){

billAmount=billAmount+(billAmount*0.15);
}

printf("Customer name: %s\n", name);

printf("Total units consumed: %d\n", unit);

printf("Total Bill Amount: %.2f\n", billAmount);

return 0;

You might also like