Given the number of electrical units consumed the task is to calculate and display the total amount payable. Follow the below given cost chart.
- Upto 50 units 2 ₹/unit
- From 51 to 150 units 4 ₹/unit
- From 151 to 300 units 6 ₹/unit
- More than 300 units 8 ₹/unit
C
#include <stdio.h>
int main()
{
int u=0,charge=0;
printf("Enter the consumed units: ");
scanf("%d",&u);
if(u>0&&u<=50)
{
charge=u*2;
}
else if(u>50&&u<=150)
{
charge=u*4;
}
else if(u>150&&u<=300)
{
charge=u*6;
}
else if(u>300)
{
charge=u*8;
}
else
{
printf("Number of units can not be zero or negative");
}
printf("Payable Amount: Rs %d",charge);
return 0;
}C