C program To Print Amount To Be Paid By A Customer Number And Power Consumed (User Input)

C program To Print Amount To Be Paid By A Customer Number And Power Consumed (User Input)

#include<stdio.h>

void main()
{
 
   int cuctomer_no,power_consumed;
   float amount;

   printf("Enter customer number:\n");
   scanf("%d", &cuctomer_no);   //input from user
 
   printf("Enter power consumed:\n");
   scanf("%d", &power_consumed);    //input from user

   if (power_consumed >= 0 &&power_consumed <= 400)  //power consumed b/w 0 to 400
      amount =power_consumed * 0.80;
   
   else if (power_consumed > 400 &&power_consumed < 600)   //power consumed b/w 400 to 600
      amount = 100 + ((power_consumed - 400) * 0.85);
   
   else if (power_consumed > 600 &&power_consumed <= 800)   //power consumed b/w 600 to 800
      amount = 230 + ((power_consumed - 600) * 0.90);
 
   printf("Amount paid by customer_no %d is Rs.:%5.2f.\n", cuctomer_no, amount);  //Print Output On screen

}
Copyright © C Program | Java | OpenGL Programming | Hadoop at Computaholics