Skip to main content

Posts

Showing posts with the label 24.Write a C program to input electricity unit charges and calculate total electricity bill according to the given condition:

ads1

24.Write a C program to input electricity unit charges and calculate total electricity bill according to the given condition:

24. Write a C program to input electricity unit charges and calculate total electricity bill according to the given condition: For first 50 units Rs. 0.50/unit For next 100 units Rs. 0.75/unit For next 100 units Rs. 1.20/unit For unit above 250 Rs. 1.50/unit An additional surcharge of 20% is added to the bill    Solution :-  #include<stdio.h> #include<conio.h> void main() {     clrscr();     int unit;     float amt,tot_amt,sur_charge;     printf("Enter the Unit 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);     }     sur_charge = amt*0.20;     tot_amt = amt+sur_charge;     printf("The Total Bill is :- %f",tot_amt); getch(); } Output :-     

ads2