i) Electricity bill ii) Telephone bill by accepting number of units & rate per unit from user (Use Function) (For electricity bill, if no. of units<100 then rate=0.5 Rs/unit, if units>100 and <500 then rate=1.5 Rs/unit and if units>=500 then rate=2.00Rs/unit) (For telephone bill, if no. of units<100 then rate=0.75 Rs./unit, if units>100 and<500 then rate=1.25 Rs/unit and if units>=500 then rate=2.00Rs/unit)
#include<stdio.h>
void electricity()
{
int unit;
float bill;
printf("Enter number of units");
scanf("%d",&unit);
if(unit<100)
bill = unit * 0.5;
else if(unit > 100 && unit < 500)
bill = unit * 1.5;
else if(unit >= 500)
bill = unit * 2;
printf(" Electricity Bill = %f",bill);
}
void telephone()
{
int unit;
float bill;
printf("Enter number of units");
scanf("%d",&unit);
if(unit<100)
bill = unit * 0.75;
else if(unit > 100 && unit < 500)
bill = unit * 1.25;
else if(unit >= 500)
bill = unit * 2;
printf(" Electricity Bill = %f",bill);
}
void main()
{
int ch;
do
{
printf("\n1.Electricity\n2.Telephone\n3.Exit\nEnter your choice....");
scanf("%d",&ch);
switch(ch)
{
case 1:
electricity();
break;
case 2:
telephone();
break;
}
}while(ch!=3);
}
#include<stdio.h>
void electricity()
{
int unit;
float bill;
printf("Enter number of units");
scanf("%d",&unit);
if(unit<100)
bill = unit * 0.5;
else if(unit > 100 && unit < 500)
bill = unit * 1.5;
else if(unit >= 500)
bill = unit * 2;
printf(" Electricity Bill = %f",bill);
}
void telephone()
{
int unit;
float bill;
printf("Enter number of units");
scanf("%d",&unit);
if(unit<100)
bill = unit * 0.75;
else if(unit > 100 && unit < 500)
bill = unit * 1.25;
else if(unit >= 500)
bill = unit * 2;
printf(" Electricity Bill = %f",bill);
}
void main()
{
int ch;
do
{
printf("\n1.Electricity\n2.Telephone\n3.Exit\nEnter your choice....");
scanf("%d",&ch);
switch(ch)
{
case 1:
electricity();
break;
case 2:
telephone();
break;
}
}while(ch!=3);
}
0 comentários:
Post a Comment