Tuesday, October 11, 2011

Program using C to calculate Electricity Bill with if-else condition


Conditions      
                <=100 Rs.4/units
                 > 100 and <=300 Rs.4.50/units
                 >300 and <=500 Rs.4.75/units
                 >500 Rs.5/units

Program
#include<stdio.h>
#include<conio.h>
void main ()
{
  int unit, tot;
  clrscr ();
  printf("Enter Total Units:");
  scanf ("%d", &unit);
   if (unit<=100)
     {
      tot=unit*4;
     }
   else if (unit>100 && unit<=300)
     {
      tot=unit*4.5;
     }

    else if (unit >300 && unit<=500)
     {
      tot=unit*4.75;
     }
   else
     {
      tot=unit*5;
     } 
    printf("Total Amount = %d", tot);
  getch ();
}

Reactions:

1 comments:

  1. Sir i need the source code of electricity billing system version which uses text file and data structure to store and manipulate records in database.

    ReplyDelete