Just a few questons I have for a review sheet.

I have an exam later and have a few questions I would like to clarify my answers if anyone could give me their input. Thanks.

1. Write the definition for a function that takes a non-negative integer n as its only input
parameter, and returns:
• the sum of the even integers greater than zero and less than n
• the sum of the odd integers greater than zero and less than n
via two separate input-output parameters.

2. Write a the definition for a function that takes an array of doubles, the array’s size and a
location (index value) as its three parameters and returns the index of the smallest value in
array via the location parameter.

3. Write the definition for a function that takes an array of integers, the size of the array, and
a key value, as its three formal parameters. Your function then returns true if the product
of any consecutive pair of elements in the array is equal to the key value, and returns false
otherwise.
Example:
Given the array 2 5 4 7 3 6 of size 6, your function would return true for key
values of 10, 20 ,28, 21, 18 and return false for all other key values. since
• 2 * 5 = 10
• 5 * 4 = 20
• 4 * 7 = 28
• 7 * 3 = 21
• 3 * 6 = 18


4. Given the following struct definition:
struct Thing
{
int scal;
double vec[2];
};
And array declaration:
Thing things[2];
(a) Draw a picture of things.
(b) Assign the scal component of the first element of things to -1.
(c) Assign the second element the vec component of the first element of things to 3.14.



Thanks for any answers!
Thanks for the exam questions!
> I would like to clarify my answers

I don't see any answers.
1. Wrong
2. Wrong
3. Wrong
4. a.) wrong
b.) wrong
c.) wrong
Topic archived. No new replies allowed.