Programming Examples

Write a program to calculate electricity bill


Write a program to calculate electricity bill. Read the starting and ending meter reading. 

The charges are as follows.

No. of units consumed Rates in (Rs.)

200–500 3.50
100–200  2.50
Less than 100 1.50

Solution

void main()
{
int initial,final,consumed;
float total;
clrscr();
printf(“\n Initial & Final Readings :”);
scanf(“%d %d”, &initial, &final);
consumed = final-initial;
if(consumed>=200 && consumed<=500)
total=consumed * 3.50;
else if(consumed>=100 && consumed<=199)
total= consumed * 2.50;
else if(consumed<100)
total=consumed*1.50;
printf(“Total bill for %d unit is %f”,consumed,total);
getche();
}
Output

OUTPUT: 

Initial & Final Readings : 800 850

Total bill for 50 unit is 75.000000

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz