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

Create a function that prints an array of ints using pointer arithmetic. Assume

ID: 3545402 • Letter: C

Question

  • Create a function that prints an array of ints using pointer arithmetic.  Assume that the caller will give you valid addresses (i.e. they are actually the starting and ending points of the array) and that you do not have to handle empty arrays.
    • Parameters:
      • pStart (int pointer) = A pointer to the start of the array
      • pEnd (int pointer) = A pointer to the end of the array (i.e. the last element in the array)
    • Returns:
      • Nothing
  • Make another function that does the exact same thing, but with strings (i.e. char pointers) instead of ints.
  • Test the functions by printing the following arrays (copy and paste these into your main function, they should make the arrays for you):
    • int iArray[] = {12, -2, 4, 123, 9, 0};
    • int iArray2[] = {1};
    • char *strArray[] = {"Hi", "I hope", "this exercise", "was", "easy", "!"};
    • char *strArray[] = {""};

Explanation / Answer

void public printInt(*pStart,*pEnd){

for(pStart;pStart<=pEnd;pStart++)

{

prinf("%d",*pStart);

}

}


void public printChar(*pStart,*pEnd){

for(pStart;pStart<=pEnd;pStart++)

{

prinf("%c",*pStart);

}

}

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