Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your program will \"drop balls\" each of which willbounce randomly and land in a

ID: 3616719 • Letter: Y

Question

Your program will "drop balls" each of which willbounce randomly and land in a slot. There will be 21 slots(numbered from -10 to 10). Each ball will be dropped over themiddle slot (number 0) and "bounce" 10 times. On each bounce theball will move (randomly) either left or right (i.e. to the slotwith one number lower or one higher). Notice that since there willbe an even number of bounces the ball will always land in aneven-numbered slot.

The program will ask the user for the number ofballs to be dropped and accept the user's answer. If the userenters a value less than 1 and error message will be displayed andthe program will continue asking until a value at least 1 isentered. The program will then drop the requested number of ballsand count how many land in each slot. A histogram will be displayedshowing how many balls landed in each slot (you need only drawhistogram lines for even-numbered slots). Use lower case 'o' forpoints in the histogram -- each 'o' will represent one ball. Thehistogram should (roughly) present a bell curve representing anormal distribution. Running the program may give a display asfollows:

Your program must be well-commented (of course),show good programming style, use several functions, and have ashort main(). Each function other thanmain() should have a function prototype.

You will use an int array, say intcatch[21], to count the number of balls which fall into thevarious slots: catch[10] will hold the number of ballswhich fall into the middle slot, catch[11] the number inthe slot to its right, catch[9] the slot one left of themiddle, etc. To "drop" a ball you will initialize a counter to 10(for the middle slot) and let it "bounce" 10 times. A bounce willrandomly add or subtract 1 from this counter. After the 10 bouncesthe value in the counter will be the slot where the ball lands --increment the corresponding position incatch[].

Explanation / Answer

please rate - thanks #include #include #include #include int getnumber(void); void getslot(int []); void print(int []); int main() {int balls=3,slotcount[21]={0},slot; int i,j; srand((unsigned)time(NULL)); balls=getnumber(); for(i=0;i