Monday, June 18, 2012

To calculate electricity bill


/* Program to calculate electricity bill */

#include<stdio.h>

#include<conio.h>

void main()

{

  int customer_id,units;

  float charges;

  clrscr();

  printf("Enter Customer's ID and Units consumed:");

  scanf("%d%d",&customer_id,&units);

  if(units<=200)

    charges=0.50*units;

  else if(units<=400)

    charges=100+0.65*(units-200);

  else if(units<=600)

    charges=230+0.8*(units-400);

  else

    charges=390+1.00*(units-600);

  printf("\nElectricity bill of ID:%d = Rs%f",customer_id,charges);

  getch();

}

 

OUTPUT

Enter Customer's ID and Units consumed:14120

524

 

Electricity bill of ID:14120 = Rs329.200012

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.