CSE 1311 - Section 2 - Assignments - Assignment 4

Due date: Wednesday, February 24, 2010, 11:55pm.


Task 1 (30 points)

The program in example.cpp allows the user to create an array of integers, of any length that the user wants, and it also allows the user to enter a value for each element in the array. Finally, the program prints out the array.

Write a program, in a file called task1.c, that is a modification of example.cpp, so that an array of doubles is created and printed instead of an array of integers. The user should be able to provide real numbers as values for the elements of the array. Feel free to copy/paste and modify code from example.cpp. Your solution should:

Hint: You will probably find it useful to use code from task 1, or from the example.cpp for the rest of the tasks in this assignment.


Task 2 (30 points)

Write a program, in a file called task2.c, that lets the user create an array of doubles and specify values for the elements of the array, and prints out the maximum value in that array. In particular, the program should perform the following steps:

For full credit, your program should define and use a function called double find_maximum(double * numbers, int length) that takes as input an array and the length of that array, and returns the largest value in that array. For partial credit, you can make a program that behaves as specified above but does not define or use the find_maximum function. For partial credit, you can make your function work with an array of ints, if you cannot get it to work with an array of doubles.


Task 3 (40 points)

Write a program, in a file called task3.c, that lets the user create an array of ints and specify values for the elements of the array, and prints out how many even numbers the array contains. In particular, the program should perform the following steps:

Your program should define and use a function called int count_even_numbers(int * numbers, int length) that takes as input an array and the length of that array, and returns how many even numbers are stored in that array. For example:


How to submit

Submisions are only accepted via WebCT. The submission should include files task1.c, task2.c, task3.c, and answers.doc. Do not submit entire project directories, or anything else except for the .c files and the answers.doc file.

Your answers.doc file should be a single Microsoft Word file that includes:

Make sure that your answers.doc file is easy to parse, and that it is easy for us to figure out which part corresponds to which task. Feel free to use headings such as "start of copy of task1.c".

We try to automate the grading process as much as possible. Not complying precisely with instructions causes a significant waste of time during grading, and thus points will be taken off for failure to comply, and/or you may receive a request to resubmit.

Submission checklist