Electricity Bill Calculation System
Mini Project Report Using C (Supporting SDG7: Affordable and Clean
Energy)
Abstract
This project demonstrates the design and implementation of an
automated electricity bill calculation system using C programming. It
employs conditional logic and functions and is inspired by the global
imperative of SDG7—to provide access to affordable and clean
energy. The system allows users to enter their electricity units and
instantly see a breakdown of their bill, encouraging wise energy
usage and transparency.
Table of Contents
1. Abstract
2. Introduction
3. Objectives
4. Problem Statement
5. Theoretical Background
6. SDG7 and Energy Equity
7. Scope of the Study
8. Methodology
9. System Requirements
10. System Design
11. Flowchart and Algorithm
12. Functional Decomposition
13. Program Code with Explanations
14. Error Handling
15. Sample Data and Extensive Table
16. Output Screenshots/Printouts
17. Discussion and Results
18. Significance to End Users
19. Application Areas
20. Limitation of Study
21. Maintenance of the System
22. Conclusion
23. Future Enhancements
24. References
25. Appendix
Introduction
Accurate metering and billing are crucial in distributing electricity
efficiently and fairly. Traditional manual computation leads to
inaccuracy and poor visibility for the consumer. This project
automates slab-based billing, promotes clarity, and gives users an
educational, hands-on view of real-world energy cost models, thus
highlighting the direct impact of electricity consumption on the
monthly budget.
Objectives
To provide a user-friendly platform for customers to compute
monthly bills.
To minimize human error via automation.
To help users envision savings through conscious consumption.
To employ C programming fundamentals in line with academic
curriculum.
To promote awareness of SDG7: Affordable and Clean Energy
for all.
Problem Statement
A significant issue for many households is bill shock due to
uncertainty about tariff structures and consumption slabs. Manual
billing errors still occur. An easy-to-use digital calculator addresses
both these challenges by increasing accuracy and awareness.
Theoretical Background
Components of an Electricity Bill
Electricity bills are typically composed of:
Basic energy charges (per kWh)
Meter rent/fixed charges
Service charges
Taxes (state and federal, if any)
Slab System
The slab system penalizes excessive use and rewards conservation
through progressive rates: the more units consumed, the higher the
rate for each additional slab.
SDG7 and Energy Equity
The United Nations’ SDG7 seeks universal access to affordable,
reliable, sustainable, and modern energy. Tools that educate and
empower consumers, such as this billing calculator, are low-cost
interventions vital for achieving energy equity.
Scope of the Study
This project focuses on a single user each run, with static tariff slabs.
However, the methodology can be adapted for more users, varying
slabs, inclusion of taxes, surcharges, or subsidy calculations.
Methodology
The solution employs procedural programming. User input is
received through the terminal; slab logic is implemented using if-else
ladders inside a function. Outputs are displayed instantly to enhance
user-friendliness.
System Requirements
Software: Any standard C Compiler (GCC/CodeBlocks/VS
Code/Turbo C)
Hardware: PC with >= 256 MB RAM
OS: Windows 7/10, Linux, or Mac OS
No additional libraries required
System Design
Input
Units consumed (integer)
Processing
Bill calculation using predefined slab logic
Output
Total bill & breakdown
Flowchart and Algorithm
Algorithm:
1. Start
2. Request electricity units input
3. Validate input
4. Calculate bill as per logic
5. Add fixed charge
6. Output total and slab breakdown
7. End
Flowchart:
(Insert a labeled flowchart showing Input → Validation → Bill
Calculation → Output)
Functional Decomposition
Input Function: Collects number of units
Validation: Checks for negative or illogical data
Calculation Function: Processes billing logic based on slabs
Display Function: Outputs results
Error Handler: Guides correction for bad input
Program Code with Explanations
#include <stdio.h>
// Calculates electricity bill as per fixed slabs
float calculateBill(int units) {
float amount = 0.0;
if (units <= 100) {
amount = units * 1.5;
} else if (units <= 300) {
amount = (100 * 1.5) + (units - 100) * 2.5;
} else if (units <= 500) {
amount = (100 * 1.5) + (200 * 2.5) + (units - 300) * 4.0;
} else {
amount = (100 * 1.5) + (200 * 2.5) + (200 * 4.0) + (units - 500) *
6.0;
amount += 50; // add fixed charge
return amount;
int main() {
int units;
float billAmount;
printf("Electricity Bill Calculator\n");
printf("--------------------------\n");
printf("Enter the number of units consumed: ");
scanf("%d", &units);
if (units < 0) {
printf("Invalid input! Units cannot be negative.\n");
} else {
billAmount = calculateBill(units);
printf("UNITS: %d\n", units);
printf("TOTAL BILL: ₹%.2f\n", billAmount);
return 0;
Explanation:
The calculateBill function clearly segments each slab.
Main function gathers input and manages user interaction.
Error Handling
If users enter negative numbers, the system politely warns and stops
processing. This prevents logical errors and encourages correct data
entry.
Sample Data and Extended Calculation Table
Serial Units Bill Amount
Bill Breakdown
No. Consumed (₹)
1 50 125.00 50 x 1.5 + 50 fixed
2 100 200.00 100 x 1.5 + 50 fixed
3 150 325.00 100 x 1.5 + 50 x 2.5 + 50 fixed
4 275 762.50 100 x 1.5 + 175 x 2.5 + 50 fixed
Serial Units Bill Amount
Bill Breakdown
No. Consumed (₹)
100 x 1.5 + 200 x 2.5 + 50 x 4.0 +
5 350 1250.00
50
100 x 1.5 + 200 x 2.5 + 200 x 4.0
6 500 1850.00
+ 50
100 x 1.5 + 200 x 2.5 + 200 x 4.0
7 520 1970.00
+ 20 x 6.0 + 50
Expand and repeat with more test data if needed.
Output Screenshots/Printouts
Discussion and Results
Multiple test cases demonstrate accuracy for each slab and logical
handling of edge cases (zero, 100, 101, 300, etc.). The tool
encourages knowledge and motivates users to stay under cheaper
slabs.
Significance to End Users
Promotes awareness of consumption and savings potential.
Reduces confusion and error compared to manual calculation.
Can be adapted for rural areas, schools, and offices as a ready
reckoner tool.
Application Areas
Homes, schools, and colleges for educational purposes
Offices seeking transparency in power expenses
Rural electrification awareness campaigns
Utility companies for customer self-service kiosks
Limitation of Study
Supports single-user one-time calculation.
No integration with online payment or database for automatic
record keeping.
Slabs are static and require manual update if regulatory rates
change.
Maintenance of the System
Routine updates should reflect changes in tariff, fixed charges, or
billing policy. Annual review recommended to ensure compliance
with current electricity board norms.
Conclusion
The Electricity Bill Calculation System provides a reliable,
educational, and highly practical tool for automating and
understanding electric bills. Its relevance extends beyond academics,
serving end-users and promoting the sustainable development goals
for affordable, clean energy.
Future Enhancements
Addition of security and multi-user authentication.
Integration with web or mobile service for anywhere access.
Export functionality for bill statements (PDF, email, SMS).
Machine learning for personalized energy-saving suggestions.
Automated tariff updates linked with government databases.
References
United Nations SDG7 Official Documentation.
Local/state regulatory electricity billing documents.
Major textbooks on C programming.
Online tutorials and blogs.
Official utility provider billing policies.
Appendix
A. Code Listing: (Already included above.)
B. Data Table: (See the extended calculation table section; repeat for
additional cases.)
C. Flowchart Diagram: (To be attached physically or digitally in your
file.)
D. Output Printouts: (Screenshots of code and outputs.)
E. Glossary
Unit: One kilowatt-hour (kWh)
Slab: A pricing level for units
Fixed Charge: A non-variable fee included in all bills