a. Define an array of type unsigned int called values with five elements, and initialize the elements to the even integers from 2 to 10. Assume the symbolic constant SIZE has been defined as 5. b. Define a pointer vPtr that points to an object of type unsigned int C. Print the elements of array values using array index notation. Use a for d. Give two separate statements that assign the starting address of array values e. Print the elements of array values using pointer/offset notation. statement and assume integer control variable i has been defined. to pointer variable vPtr.

Get full solution in 10 Seconds

EXPERT ANSWER

Answer a:
int values[5] = {2,4,6,8,10};
Explanation:
Array values is initialized with 5 even numbers

Answer b:
int *vPtr;
Explanation:
vPtr is a pointer to point to an integer object, we must declare it as type int*. The first part int is where we are determining the data type the pointer is pointing to, and the second part * is how we make the variable a pointer.

Answer c:
for (i = 0; i < SIZE; i++)
printf (“%d “, values[i]);

Explanation:
Using for loop to print all the the elements the elements of the array

Answer d:
vPtr = values;
vPtr = &values[0];

Explanation:
Since values is the address of the first element of the array, this is a valid way to assign the first element in the values array to the vPtr pointer. Take care not to use the * operator when you really want an address, as in this case.
Since values[0] is the first element of the array, we use &values[0] as the starting address of the array to assign to vPtr


Answer e:
for (i = 0; i < SIZE; i++)
printf (“%d “, *(vPtr + i));

Explanation:
Using for loop along with the pointer to print all the elements in an array.