Programming Examples

Cpp program to calculate electricity bill


Write a cpp program to calculate Electricity Bill.

Meter rent: ₹500

First 100 units :  80 paisa per unit

Next 200 units : ₹1 per unit

Above 300 units: ₹ 2.50

Solution

#include
using namespace std;
int main()
{
     float tuc,cost;
     cout<<"Calculate your elctricity bill\n";
     cout<<"Enter the number of units consumed:";
     cin>>tuc;
     if(tuc<=100)
     {
          cost=(tuc*.8)+500;
     }
     else if(tuc<=300)
     {
          cost=(100*.8)+(tuc-100)*1+500;
     }
     else
     {
          cost=(100*.8)+(200*1)+(tuc-300)*2.50+500;
     }
     cout<<"Total bill:"<     return 0;
}
Output

Calculate your electricity bill

Enter the number of units consumed:101

Total bill:581

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