Calculate Electricity Bill with if-else condition
<=100 Rs.4/units
> 100 and <=300 Rs.4.50/units
>300 and <=500 Rs.4.75/units
>500 Rs.5/units
<=100 Rs.4/units
> 100 and <=300 Rs.4.50/units
>300 and <=500 Rs.4.75/units
>500 Rs.5/units
#include<stdio.h>
#include<conio.h>
void main ()
Method 2:(Coded by: Manpreet Singh Dhindsa, Patiala )
#include<stdio.h>
#include<conio.h>
void main()
{
int units;
float total_bill;
clrscr();
printf("Enter the no. of units");
scanf("%d",&units);
if(units <= 100)
total_bill = units * 4;
else if(units <= 300)
total_bill = units * 4.5;
else if(units <= 500)
total_bill = units * 4.75;
else
total_bill = units * 5;
printf("the bill to be paid is = %f", total_bill);
getch();
}
Question by: Simi Sandhu @ C Programming Facebook Page
No comments:
Post a Comment