Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 9 Not complete Marked out of 1.00 P Flag question Write a function void

ID: 3742868 • Letter: Q

Question

Question 9 Not complete Marked out of 1.00 P Flag question Write a function void print int vector(int *ptr, int length) that prints the values in the vector of integers indicated by ptr of length length to the standard output A vector is a 1-dimensional array. For example, the following C statement declares an integer vector of 10 elements: int aVector [10]; Each integer should be printed as a decimal number, one entry per line You should not provide the main) function - - only implement the print_int vector function as described above. You may want to refresh your background in pointers using this reference (https://www.cprogramming.com/tutorial/c/lesson6.html ) You may also want to refresh yourself concerning C arrays https://www.cprogramming.com/tutorial/c/lesson8.html) Answer: (penalty regime 0 %) Reset answer 1 lvoid print_int_vector(int *ptr, int length) 3your code here */ 4

Explanation / Answer

void print_int_vector(int *ptr,int length)

{

int i;

for(i=0;i<length;i++) //iterates through the vector

{

float vector=(float)*ptr; // converts ist value of vector to float. *ptr gives the value of the vector

printf("%.3f ",vector); //displays 3 digit decimal and prints the value of vector

ptr++; // moves to next value of vector. ptr without * increments to next memory location

}

}

**** *ptr gives the value of the array at paticular memory location. ptr gives address of the memory location. ***

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote