0% found this document useful (0 votes)
9 views

Demo 1

This C program calculates electricity bills and subsidies based on the number of units consumed. It prompts the user to enter details like consumer name, reference number, units consumed, number of services. Based on the units consumed, it calculates the bill amount and applicable subsidy using different slab rates and prints the output. The program runs in a continuous loop to allow for multiple calculations.

Uploaded by

webprogram32
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Demo 1

This C program calculates electricity bills and subsidies based on the number of units consumed. It prompts the user to enter details like consumer name, reference number, units consumed, number of services. Based on the units consumed, it calculates the bill amount and applicable subsidy using different slab rates and prints the output. The program runs in a continuous loop to allow for multiple calculations.

Uploaded by

webprogram32
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<stdio.

h>
int main()
{
int units,months,reference_num,services;
char consumer_name,category;
float subsidy,bill_amount;
while(1) //for continous
calculations
{
printf("Enter the name of consumer\n");
scanf("%s",&consumer_name); //without '&'
getting error in online compilers me
printf("Enter the bill reference number\n");
scanf("%d",&reference_num);
printf("Enter the amount of units consumed\n");
scanf("%d",&units);
/* IF MORE THAN 2 MONTHS ARE THERE THEN =>
printf("Enter the number of months\n");
scanf("%d",&months);*/
printf("Enter the number of service\n");
scanf("%d",&services);
if(units>=0)
{
if(units<=100)
{
bill_amount = (2.50*units)+(30*services);
printf("BILL AMOUNT : ₹ %10.2f\n",bill_amount);
printf("SUBSITY : NO SUBSIDY\n");
}
else if(units<200)
{
bill_amount = (2.50*units)+(30*services);
subsidy = (1.50*(units-100))+(20*services);
printf("BILL AMOUNT : ₹ %10.2f\n",bill_amount);
printf("SUBSIDY : ₹ %10.2f\n",subsidy);
}
else if(units<500)
{
bill_amount = (2.50*200)+(3.00*(units-200))
+(40*services);
subsidy = (2.00*100)+(3.00*(units-200))
+(30*services);
printf("BILL AMOUNT : ₹ %10.2f\n",bill_amount);
printf("SUBSIDY : ₹ %10.2f\n",subsidy);
}
else if(units>500)
{
bill_amount =
(2.50*100)+(3.50*100)+(4.60*300)+(6.60*(units-500))+(50*services);
subsidy = (3.50*100)+(4.60*300)+(6.60*(units-500))
+(50*services);
printf("BILL AMOUNT : ₹ %10.2f\n",bill_amount);
printf("SUBSIDY : ₹ %10.2f\n",subsidy);
}
}
else
printf("No units consumed\n");
}
return 0;
}

You might also like