29 September 2010

C Program 2 – Electricity Bill calculation

This program is to display the electricity bill calculation based on the number of units consumed every month

Input : the number of units – variable name – unit

Output – Amount of rupee – variable name – amount

Logic:

Units Rupees
1-50 units 0.75/unit
51-100 0.85/unit
101-200 1.50/unit
201-300 2.20/unit
>300 3.00/unit

In all the cases, there will be service charge of Rs.20 will be collected.

#include <stdio.h>
#include <conio.h>
int main()
{
    float amount=0,units;;
    printf("Enter the number of units");
    scanf("%f", &units);
    if(units <=50)
    {
     amount = units * 0.75;       
    }   
    else if(units >50 && units <=100)
    {
         amount=0.75 * 50 + 0.85*(units-50);
    }
    else if(units >100 && units <200)
    {
         amount=(0.75*50) + (0.85*50 )+ (1.5 *(units-100));
    }
    else if(units >200 && units <300)
    {
         amount=(0.75*50) + (0.85*50 )+ (1.5 *100) + (2.20 *(units-200));
    }
    else
    {
         amount=(0.75*50) + (0.85*50 )+ (1.5 *100) + (2.20 * 100) +(3.0*(units-300));
    }
    amount=amount+(0.2*amount);
    printf("The total electricity bill is %f", amount);
    getch();
    return 0;
}


9 comments:

  1. please write few line, it will be easy to understand

    ReplyDelete
  2. too short...please extend it

    ReplyDelete
  3. i need c code for spot billing machine

    ReplyDelete
  4. helps very good...!!!!

    ReplyDelete
  5. if th units used is greater than 300 an intrest of 15% wil b given then hw 2 modify ys pgm

    ReplyDelete
  6. it gies good ideas"THANK U".good

    ReplyDelete
  7. dear sir ,
    i wants write a program in c language to print an item (or product) bill with use of item_name, item_price, quantity_of_items,sell_item and total_of_amount.
    so i need a help to make this type of program in c language.

    thanks.....!

    ReplyDelete
  8. Helps very much yaar...!And could understand it very clearly.Thanks..!

    ReplyDelete

Powered by Blogger.

About Me

Featured Post

5G Network Simulation in NS3 using mmWave | NS3 Tutorial 2024

5G Network Simulation in NS3 Using mmWave This post shows the installation of ns3mmwave in Ubuntu 24.04 and simulates 5G networks in ns3. In...

Contact form

Name

Email *

Message *

Total Pageviews

Search This Blog

Pages

Pages

Pages - Menu

Most Popular

Popular Posts