Question: Write a C program which populates a five-element array of integers using a dereferenced pointer. First, create the array and initialize it with all zeros.

Write a C program which populates a five-element array of integers using a dereferenced pointer. First, create the array and initialize it with all zeros. Next, create a pointer of the same type and assign to it the starting address of the array. Then, use a loop, together with the scanf ( ) command to prompt the user to enter five integers, one at a time. On each loop iteration, store the value into the array using the pointer; do not use the array variable. Afterwards, increment the pointer to the next element to prepare for storing the next value. After the array has been fully populated, print the contents of the array using pointer dereferencing. You may reset the pointer's stored address back to the start of the array if you prefer. See the sample output provided below. Your code should not use the "array[ ]" notation anywhere for storing or printing array values. Enter a numeric value for element 0:6 Enter a numeric value for element 1:8 Enter a numeric value for element 2: 11 Enter a numeric value for element 3:9 Enter a numeric value for element 4:5 The array's contents are: 6,8,11,9,5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
