Focusing on Intermediate Programming
Question
-Focusing on Intermediate Programming
1. Write a function that takes an array of integers as a
parameter and returns the sum of odd numbers in the array. Assume the array has MAX elements where MAX is a global constant integer. This means that before all of the functions there should be a declaration like:
const int MAX = 10;
And arrays are declared like:
int myArray[MAX];
2. Rewrite your answer to the previous question as a recursive function.
3. Use a sorting algorithm of your choice to sort an array of at least 25 elements. Your text describes insertion sort in section 7.8. If you use another method, be sure to cite your source material. Write a main method that demonstrates your solution.
4. Write a function that is passed two parameters: a one-dimensional array of int values, and an integer value. The function finds the value in the array that is closest in value to the second parameter.
For example, if the array had the values {5, -3, 18, 9, 4} and the second parameter was 11, then the function would return 9, because 9 is the closest value in the array to 11.
If two values are equally distant, return either. In the previous example, if the second parameter was 7, either 5 or 9 could be returned.
Assume the array has MAX elements where MAX is a global constant int.
5. Read in 20 numbers from a user, each of which is between 30 and 90, inclusive. As each number is read, validate it and store it in an array if and only if it is not a duplicate of a number already read. After reading all the numbers, show only the unique values. For example, if 35 was entered three times, show it just once. Use one single array of the smallest possible size to solve the problem. You may use as many functions as desired.
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"
