A book donation box that can take up to 50 books was put outs.de a library Write
ID: 3938305 • Letter: A
Question
A book donation box that can take up to 50 books was put outs.de a library Write a C program that is able to keep track of the amount of books in the box. The program will ask the donor to input the amount of books to be donated Then, it will display the total amount of books in the box after the donate is done This should run continuously until someone tries to donate a batch of books that causes the total amount of books m the box to be more than 50. Then, the program should give a message informing the donor that the box is full and the number of books to be returned to the donor. Then, the program will end Figure Q3 shows an example of the program outputExplanation / Answer
#include<stdio.h>
int main()
{
int b=0;
int tot=0;
while(tot<=50)
{
printf("please enter no of books donated : ");
scanf("%d",&b);
tot=tot+b;
if(tot<=50)
printf(" there are %d books in the box",tot);
else
{
printf(" Box is full");
printf("%d books to be returned ",tot-50);
break;
}
}
printf(" press any key t continue");
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.