Due date: Wednesday, March 3, 2010, 11:55pm.
Task 1 (20 points)
Write a program called task1.c or task1.cpp, that behaves as follows:
- It asks the user to enter two integers A and B.
- If A > B, the program exits without doing anything more. For the next steps, we assume that A <= B.
- It creates an array of integers containing, in DESCENDING order, all integers between A and B. For example, if the user enters value 6 for A and 8 for B, the array should have value 8 stored at element 0, value 7 stored at element 1, and value 6 stored at element 2.
- It prints out the contents of the array, one by one.
For full credit, you should implement a function int * make_descending(int A, int B), that creates and returns an array of integers containing, in DESCENDING order, all integers between A and B. Solutions not implementing this function will get at most half credit.
Task 2 (20 points)
Write a program called task2.c or task2.cpp, that behaves as follows:
- Asks the user to enter 5 numbers of type double.
- Stores those numbers in an array of doubles.
- Prints out the average of those numbers.
For full credit, you should implement a function ... compute_average(double * numbers, ...), that
computes the average of all values stored in the array numbers. You have to figure out the return type for this function (intentionally left unspecified), and whether you need to pass any additional argument or arguments and the type of those arguments. Solutions not implementing this function will get at most half credit.
Task 3 (20 points)
Write a program, in a file called task3.c or task3.cpp, that:
- Asks the user to enter two integers A and B.
- If A > B, the program exits without doing anything more. For the next steps, we assume that A <= B.
- It prints the number of odd integers between A and B (including A and B). For example, if A = 13 and B = 17, the program should print 3.
For full credit, you should implement a function ... count_odds(int A, int B), that computes and returns the number of odd numbers between A and B(including A and B). You need to figure out the return type for that function. Solutions not implementing this function will get at most half credit.
Task 4 (20 points)
Write a program, in a file called task4.c or task4.cpp, that:
- Asks the user to enter an integer A.
- It prints the following product: A * (A - 0.5) * (A + 0.5). For example, if A = 2, the program should print 7.5 (which equals 2 * 1.5 * 2.5).
For full credit, you should implement a function ... compute_result(int A), that computes and returns A * (A - 0.5) * (A + 0.5). You need to figure out the return type for that function. Solutions not implementing this function will get at most half credit.
Task 5 (20 points)
Write a program, in a file called task5.c or task5.cpp, that:
- Asks the user to enter integers A and B.
- If A > B, the program exits without doing anything more. For the next steps, we assume that A <= B.
- It prints the product of all integers between A and B (including A and B). For example, if A = 3 and B = 5, the program should print 60 (which is 3*4*5).
For full credit, you should implement a function ... compute_product(int A, int B), that computes and returns product of all integers between A and B (including A and B). You need to figure out the return type for that function. Solutions not implementing this function will get at most half credit.
How to submit
Submisions are only accepted via WebCT. The submission should include your C or C++ source files, and answers.doc. Do not submit entire project directories, or anything else except for the .c and .cpp files and the answers.doc file.
Your answers.doc file should be a single Microsoft Word file that includes:
- Your name and UTA ID number at the top.
- A copy of your code for each task where you had to write code.
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
- Was the assignment submitted via WebCT?
- Did answers.doc contain your name and UTA ID?
- Did the submission include files your C or C++ source files, answers.docs, and nothing else?