DOC PREVIEW
Cal Poly CPE 101 - lab 05

This preview shows page 1 out of 3 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CPE 101 Fall 2009 Laboratory 5 – Part 2 (Loops and arrays) Due Date • Friday October 23rd, 11:59pm • You must turn in your source electronically on vogon using the handin command – instructions are provided in below. Objectives • To practice writing loops. • To practice using arrays. • To practice writing functions. • To practice problem solving. • To develop a complete C program, compile it, and turn it in electronically. • To practice using file redirection for input and output. • To practice using diff to test the accuracy of output. Resources • This is a pair programming assignment; we will be keeping the same partners assigned for part 1. • You may use your instructor, peers, texts, and your own innate capabilities and resourcefulness! Ground Rules • None Orientation… This lab will involve developing a small C program to compute the average age of a large number of people (in this case 10). You must develop the specified functions, using the specified data types (namely arrays). Part 1: Develop a function to print an array of doubles. The function will take two arguments, the array of doubles and the size of the array. Print the values with only a space between them with a final newline at the end of the input. Part 2: Develop a function to prompt the user for inputDevelop a function that prompts the user for their age (see example run). The function should take two arguments, the array of doubles and the size of the array. Fill in the array with the user’s input. Part 3: Develop a function to compute the average age of all inputs Develop a function that computes the average value of all the array values. The function should take two arguments, the array of doubles and the size of the array. The function should return the average value. Part 4: Complete the program Your main function should declare any necessary variables and only call the three functions you’ve written. Below is the output of a sample run with only ten values. Enter age: 18 Enter age: 19 Enter age: 18.5 Enter age: 20 Enter age: 21 Enter age: 19 Enter age: 19.25 Enter age: 20.5 Enter age: 18 Enter age: 19 18.00 19.00 18.50 20.00 21.00 19.00 19.25 20.50 18.00 19.00 Average Age is 19.23 Part 5: Test your results against the instructor provided input and output files 1. Download the three sample input files from the class webpage (http://www.csc.calpoly.edu/~zwood/teaching/csc101/examples)2. Use file redirection to create your own output from the sample input 3. Be sure to match the output exactly by using diff Part 6: Handing in Your Source Electronically… 4. Transfer your file (lab5p2.c) to vogon as you’ve done for previous labs 5. Log on to vogon using the Secure Shell Client program (or your favorite equivalent). 6. Change directory (cd-command) to the directory containing the source file or files to hand in. 7. Execute the following command: handin zwood csc101lab05 lab5p2.c 8. You should see messages that indicate handin occurred without error. You can (and should) always verify what has been handed in by executing the following command: handin zwood


View Full Document

Cal Poly CPE 101 - lab 05

Documents in this Course
Load more
Download lab 05
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view lab 05 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view lab 05 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?