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;
}

Comments

  1. thanks really helped

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

    ReplyDelete
  3. too short...please extend it

    ReplyDelete
  4. i need c code for spot billing machine

    ReplyDelete
  5. helps very good...!!!!

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

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

    ReplyDelete
  8. 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
  9. Helps very much yaar...!And could understand it very clearly.Thanks..!

    ReplyDelete

Post a Comment

Popular Posts