Saturday 22 June 2013

An Electric power Distribution Company charges its domestic consumers as follows: Consumption units.

## An Electric power Distribution Company charges its domestic consumers as follows:
Consumption units                                                   Rate of charge
       0-200                                                                 2.5 taka per unit
      201-400                                                              100 taka plus 3 taka per unit excess of 200
     401-600                                                               250 taka plus 4 taka per unit excess of 400
     601 and above                                                     400 taka plus 5 taka per unit excess of 600
Write a C program which reads the customers amount of power consumed and prints the
amount to be paid by the customer.



Code:
#include<stdio.h>
#include<conio.h>
int main()
{
int n, p;
float amount;
printf("Enter the customer number: ");
scanf("%d",&n);
printf("Enter the power consumed: ");
scanf("%d",&p);
if(p>=0 && p<=200)
    amount=p*2.5;
else if(p>=201 && p<=400)
    amount = 100+((p-200) * 3);
else if(p>=401 && p<=600)
    amount = 250 + ((p-400) * 4);
else if(p>=601)
    amount = 400+((p-600) * 5);
printf("Amount to be paid by customer no. %d is Tk.:%5.2f.",n,amount);
getch();

return 0;

}

No comments:

Post a Comment