C Program to Calculate Electricity Bill

C Program to Calculate Electricity Bill

C program to calculate electricity bill; Through this tutorial, we will learn how to calculate electricity bill in c program.

Using the following condition, write a c program to calculate electricity unit charge and calculate the total electricity bill according to the given condition:

  • For first 50 units Rs. 0.50/unit
  • For next 100 units Rs. 0.75/unit
  • For next 100 units Rs. 1.20/unit
  • For unit above 250 Rs. 1.50/unit
  • An additional surcharge of 20% is added to the bill.

C Program to Calculate Electricity Bill

 * C program to calculate total electricity bill

#include <stdio.h>

int main()
    int unit;
    float amt, total_amt, sur_charge;

    /* Input unit consumed from user */
    printf("Enter total units consumed: ");
    scanf("%d", &unit);

    /* Calculate electricity bill according to given conditions */
    if(unit <= 50)
        amt = unit * 0.50;
    else if(unit <= 150)
        amt = 25 + ((unit-50) * 0.75);
    else if(unit <= 250)
        amt = 100 + ((unit-150) * 1.20);
        amt = 220 + ((unit-250) * 1.50);

     * Calculate total electricity bill
     * after adding surcharge
    sur_charge = amt * 0.20;
    total_amt  = amt + sur_charge;

    printf("Electricity Bill = Rs. %.2f", total_amt);

    return 0;

The output of above c program; as follows:

Enter total units consumed: 120
Electricity Bill = Rs. 93.00

Recommended C Program


Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

One reply to C Program to Calculate Electricity Bill

  1. very good website

Leave a Reply

Your email address will not be published. Required fields are marked *