Q-23.Write a C program to input electricity unit charge and calculate the total electricity bill according to the given condition.

0
বিদ্যুৎ ইউনিট চার্জ ইনপুট এবং একটি মোট বিদ্যুৎ বিল হিসাব অনুযায়ী একটি সি প্রোগ্রাম লিখুন
প্রদত্ত অবস্থা |


  1. int main()
  2. {
  3.     int unit; //declare variable unit
  4.     //first we understand unit prize
  5.     /*1 - 100 unit - 5/=
  6.       101-200 unit -  7/=
  7.       201-300 unit - 10/=
  8.       above 300  - 15/=
  9. for example*/
  10.       printf("Enter total units consumed: ");
  11.       scanf("%d",&unit);
  12.       if(unit>0 && unit<=100){//when this statement is true
  13.             printf("Bill amount is: ");
  14.     printf("%d",unit*5);//this statement is Executed otherwise
  15. }
  16. else if(unit>100 && unit<=200){//when this statement is true
  17.         printf("Bill amount is: ");
  18.     printf("%d",(100*5)+(unit-100)*7);//this statement is Executed otherwise
  19. }
  20. else if(unit >200 && unit<=300){//when this statement is true
  21.     printf("Bill amount is: ");
  22.     printf("%d",(100*5)+(100*7)+(unit-200)*10);//this statement is Executed otherwise
  23. }
  24. else if(unit >300){//when all statements are false
  25.     printf("Bill amount is: ");//consumed above 30 units
  26.     printf("%d",(100*5)+(100*7)+(100*10)+(unit-300)*15);
  27.     //this statement is Executed otherwise
  28. }
  29. else{//all statements are false
  30.     printf("No charges");
  31. }//this statement is executed
  32. getch();
  33.     return 0;
  34. }
                                                                  OUTPUT


Post a Comment

0Comments
Post a Comment (0)