Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Assignment #4 CS-2301, B-Term 20091 Programming Project #4 Arrays and Pointers Due, November 24, 11:59 PM (Assignment adapted from C: How to.

Similar presentations


Presentation on theme: "Programming Assignment #4 CS-2301, B-Term 20091 Programming Project #4 Arrays and Pointers Due, November 24, 11:59 PM (Assignment adapted from C: How to."— Presentation transcript:

1 Programming Assignment #4 CS-2301, B-Term 20091 Programming Project #4 Arrays and Pointers Due, November 24, 11:59 PM (Assignment adapted from C: How to Program, 5 th and 6 th editions, by Deitel and Deitel) Heads up:– Project is due on Tuesday before Thanksgiving break!

2 Programming Assignment #4 CS-2301, B-Term 20092 Objectives Create and allocate arrays of data Pass arrays as arguments to functions Allow functions to modify the contents of arrays Use pointer arithmetic for arrays See handout (.doc,.html)dochtml

3 Programming Assignment #4 CS-2301, B-Term 20093 Assignment Copy playGame, rollDice from Project #3. Modify playGame as follows:– Do not print anything Return an integer indicating number of throws of this game –Positive if player wins, negative if player loses Add additional functions in separate.c file Play a number of games and store results in an array Print mean and median number of throws per game Analyze the results and print table showing results Multiple modules (.c files) with makefile

4 Programming Assignment #4 CS-2301, B-Term 20094 Program Operating Prompt for number of games to play Allocate an array with that number of elements Play the games, gather results in array Calculate and print mean and median number of throws per game Calculate and print the following:– Probability of the player winning at craps Percent won on 1 st throw, 2 nd throw, etc. (up to 20) Percent lost on 1 st throw, 2 nd throw, etc. (up to 20) Do chances of winning improve with number of throws

5 Programming Assignment #4 CS-2301, B-Term 20095 Calculating Median Median – the middle value of all the results Store data in array Sort by value Select the middle value See handout for formula Sorting the data Use BubbleSort — see handout

6 Programming Assignment #4 CS-2301, B-Term 20096 Makefile Your program must comprise at least two.c files and one.h file. Recommend three and two One each for bubblesort.c and bubblesort.h Must include a makefile To build entire project To build an individual.o file To clean the directory See Lab #4

7 Programming Assignment #4 CS-2301, B-Term 20097 Grading Total 25 points Program organization & makefile – 5 points Correct compilation without warnings – 2 points Correctly allocating and freeing array, playing n games, and storing results Sorting array, calculating mean and median Building table or data structure and answering four questions – 5 points Write-up – 3 points Extra credit – 5 points Use optional command line arguments for number of games and random number seed — see handout

8 Programming Assignment #4 CS-2301, B-Term 20098 Questions?


Download ppt "Programming Assignment #4 CS-2301, B-Term 20091 Programming Project #4 Arrays and Pointers Due, November 24, 11:59 PM (Assignment adapted from C: How to."

Similar presentations


Ads by Google