28: W.A.P. to calculate electricity bill.( <=100 RS.4 / units) >100 and <=300 Rs. 4.50 / units >300 and <=500 Rs. 4.70 / units >500 Rs. 5/units.

 

28: W.A.P. to calculate electricity bill.( <=100 RS.4 / units) >100 and <=300 Rs. 4.50 / units

>300 and <=500 Rs. 4.70 / units >500 Rs. 5/units.

 

Program:

#include <stdio.h>

#include <conio.h>

 

void main()

{

    clrscr();

    int unit;

 

    printf("Enter the unit = ");

    scanf("%d", &unit);

 

    if (unit <= 100)

    {

        printf("\nYour electric bill = %f", unit * 4.0);

    }

    else if (unit > 100 && unit <= 300)

    {

        printf("\nYour electric bill = %f", unit * 4.50);

    }

    else if (unit > 300 && unit <= 500)

    {

        printf("\nYour electric bill = %f", unit * 4.70);

    }

    else if (unit > 500)

    {

        printf("\nYour electric bill = %f", unit * 5.0);

    }

    else

    {

        printf("\nWrong Unit.");

    }

    getch();

}

 

Please follow me for more practicals....


Output:

Enter the unit = 440

 

Your electric bill = 2068.000000


Please follow me for more practicals....


Algorithm:

1.      START

2.      Declare unit.

3.      Enter the value of unit.

4.      If (unit <= 100) then goto step 5 else goto step 6.

5.      Display unit * 4.

6.      If (unit > 100 && unit <= 300) then goto step 7 else goto step 8.

7.      Display unit * 4.50.

8.      If (unit > 300 && unit <= 500) then goto step 9 else goto step 10.

9.      Display unit * 4.70.

10.  If (unit > 500) then goto step 11 else goto step 12.

11.  Display unit * 5.

12.  Display Wrong unit.

13.  STOP.


Please follow me for more practicals....

 

Flowchart:

 





Please follow me for more practicals....

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.