# Total Tariff for different range of consumption in C program

We have different range of charges for consumption of units in a tariff plan. This is followed in the principle that higher charges for higher consumption.

Based on total units consumed, here is the different rate for different range of consumption.
1. Tariff Rs 1 per units for first 50 units
2. Tariff Rs 2 per units for next 100 units
3. Tariff Rs 3 per units for next 100 units
4. Tariff Rs 4 per units for more than 250 units
There is a surcharge of 10% on total bill if the consumption is more than 150 units. Find out the bill amount for different unit of consumption.

## Sample output

Here is the answer , check this output against different values of units consumed.
Units ConsumedUnit based tariff SurchargeBill Final
4545045
5050050
751000100
1502500250
20040040440
25055055605
30075075825
40011501151265

## Code is here

``````#include <stdio.h>
int main(void)
{
int slab1=0,slab2=0,slab3=0,slab4=0;
int rate1=1,rate2=2,rate3=3,rate4=4;
int units=0,total_tariff=0,final_tariff=0,surcharge=0;
printf("Enter the units consumed : ");
scanf("%d",&units);
if(units <= 50)	{
total_tariff= (units*rate1);
}else if(units <= 150  ){
total_tariff= (50*rate1) + ((units-50) * rate2);
}else if(units <=250 ){
total_tariff= (50*rate1) + (100 * rate2) + ((units-150) * rate3);
}else if(units >250){
total_tariff= (50*rate1) + (100 * rate2) + (100 * rate3) +
((units-250) * rate4);
}

printf("Unit based tariff : %d \n",total_tariff);
if(units>150){
surcharge=	total_tariff*0.1;
printf("Surcharge %d \n",surcharge);
}else{
surcharge=0;
printf("Surcharge 0 \n");
}
final_tariff=total_tariff + surcharge;
printf("Bill Final %d : ",final_tariff);
return 0;
}``````

## Subscribe

* indicates required
Subscribe to plus2net

plus2net.com

 17-01-2021 REM It's an exam program Print “ ” A= 50 B= 30 C = A * B Print “ The result is “, C