Q5: Write a program for Electric bill distribution by using
if else condition or switch case.
#include<stdio.h>
#include<conio.h>
void main()
{
int unit,rs;
clrscr();
printf("\t\tElectric
Bill\n");
printf("\t\tEnter
the unit for any particular user:");
scanf("%d",&unit);
if(unit<=200)
{
rs=0.5
* unit;
printf("\t\tThe
amount to be paid:\n\t\tRs.%d/-",rs);
}
if(unit>200
&& unit<=400)
{
rs=100+(unit
* 0.65);
printf("\t\tThe
amount to be paid:\n\t\tRs.%d/-",rs);
}
if(unit>400
&& unit<=600)
{
rs=200+(0.80
* unit);
printf("\t\tThe
amount to be paid:\n\t\tRs.%d/-",rs);
}
if(unit>600)
{
rs=425+(1.25
* unit);
printf("\t\tThe
amount to be paid:\n\t\tRs.%d/-",rs);
}
getch();
}
No comments:
Post a Comment