1 / 8

Programming Project #4 Arrays and Pointers

Heads up:– Project is due on Tuesday before Thanksgiving break!. 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). Objectives. Create and allocate arrays of data

jengle
Download Presentation

Programming Project #4 Arrays and Pointers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. 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) Programming Assignment #4

  3. 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 Programming Assignment #4

  4. 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 1st throw, 2nd throw, etc. (up to 20) • Percent lost on 1st throw, 2nd throw, etc. (up to 20) • Do chances of winning improve with number of throws Programming Assignment #4

  5. 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 Programming Assignment #4

  6. 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 Programming Assignment #4

  7. 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 Programming Assignment #4

  8. Questions? Programming Assignment #4

More Related