বিদ্যুৎ ইউনিট চার্জ ইনপুট এবং একটি মোট বিদ্যুৎ বিল হিসাব অনুযায়ী একটি সি প্রোগ্রাম লিখুন
প্রদত্ত অবস্থা |
প্রদত্ত অবস্থা |
- int main()
- {
- int unit; //declare variable unit
- //first we understand unit prize
- /*1 - 100 unit - 5/=
- 101-200 unit - 7/=
- 201-300 unit - 10/=
- above 300 - 15/=
- for example*/
- printf("Enter total units consumed: ");
- scanf("%d",&unit);
- if(unit>0 && unit<=100){//when this statement is true
- printf("Bill amount is: ");
- printf("%d",unit*5);//this statement is Executed otherwise
- }
- else if(unit>100 && unit<=200){//when this statement is true
- printf("Bill amount is: ");
- printf("%d",(100*5)+(unit-100)*7);//this statement is Executed otherwise
- }
- else if(unit >200 && unit<=300){//when this statement is true
- printf("Bill amount is: ");
- printf("%d",(100*5)+(100*7)+(unit-200)*10);//this statement is Executed otherwise
- }
- else if(unit >300){//when all statements are false
- printf("Bill amount is: ");//consumed above 30 units
- printf("%d",(100*5)+(100*7)+(100*10)+(unit-300)*15);
- //this statement is Executed otherwise
- }
- else{//all statements are false
- printf("No charges");
- }//this statement is executed
- getch();
- return 0;
- }
OUTPUT