100% program to print electricity bills of multiple houses
/* program to generate electricity bill for multiple houses(LT). let the tariff be as follows
Units Rs/ unit
1-50 1.25
51-100 2.00
101-200 3.50
>200 5.50 */
#include<stdio.h>
void main()
{
int n,status=2;//initial status is taken as any non-zero number as we want the prog to run& generate bill atleast once
float bill_amt;
while(status)
{
printf("\n enter the number of units consumed:");
scanf("%d",&n);
if(n>0 && n<=50)
bill_amt=n*1.25;
else if(n>50 && n<=100)
bill_amt=50*1.25+(n-50)*2.00;
else if(n>100 && n<=200)
bill_amt=50*1.25+50*2.00+(n-100)*3.50;
else
bill_amt=50*1.25+50*2.00+ 100*3.50+(n-200)*5.50;
printf("\n bill amount = %f", bill_amt);
printf("\n enter a non-zero number to continue else enter 0 to stop: ");
scanf("%d",&status);
};//end of while loop
}//end of main
void main()
{
int n,status=2;//initial status is taken as any non-zero number as we want the prog to run& generate bill atleast once
float bill_amt;
while(status)
{
printf("\n enter the number of units consumed:");
scanf("%d",&n);
if(n>0 && n<=50)
bill_amt=n*1.25;
else if(n>50 && n<=100)
bill_amt=50*1.25+(n-50)*2.00;
else if(n>100 && n<=200)
bill_amt=50*1.25+50*2.00+(n-100)*3.50;
else
bill_amt=50*1.25+50*2.00+ 100*3.50+(n-200)*5.50;
printf("\n bill amount = %f", bill_amt);
printf("\n enter a non-zero number to continue else enter 0 to stop: ");
scanf("%d",&status);
};//end of while loop
}//end of main
ఔట్పుట్ తెర మీద ఇలా ...
enter the number of units consumed:20
bill amount = 25.000000
enter a non-zero number to continue else enter 0 to stop4
enter the number of units consumed:204
bill amount = 534.500000
enter a non-zero number to continue else enter 0 to stop0
bill amount = 25.000000
enter a non-zero number to continue else enter 0 to stop4
enter the number of units consumed:204
bill amount = 534.500000
enter a non-zero number to continue else enter 0 to stop0
కామెంట్లు
కామెంట్ను పోస్ట్ చేయండి
దయచేసి మీ సలహాలను సూచనలను స్పష్టంగా పేర్కొనగలరు. plz see that ur comments are 'acceptable' in a value based society.