Question #16766

write a program to calculate electricity bill. if the units consumed are equal or less 100 then the cost of per unit is 5,if units consumed are more than 100 and less than 200 then the cost is 7 per unit and if units consumed are more than 200 then the cost is 9 per unit

Expert's answer

#include<iostream.h>

int U;

float C;

void main(){

cout<<"Consumed units: ";

cin>>U;

if (U<=100) C = 5*(float)U;

if ((U>100)&&(U<=200)) C = 7*(float)U;

if (U>200) C = 9*(float)U;

cout<<"Price: "<<C<<"\n";

}

int U;

float C;

void main(){

cout<<"Consumed units: ";

cin>>U;

if (U<=100) C = 5*(float)U;

if ((U>100)&&(U<=200)) C = 7*(float)U;

if (U>200) C = 9*(float)U;

cout<<"Price: "<<C<<"\n";

}

## Comments

## Leave a comment