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

Write the statements to declare an array of 10 characters called name, declare a

ID: 3554892 • Letter: W

Question

  1. Write the statements to declare an array of 10 characters called name, declare a character pointer called nameptr, and initialize nameptr to point to the first element of name.
  2. Now declare nameptr and initialize it to point to the fourth element of name.
  3. If ptr is a pointer to a character and has been initialized to point to the first element of arr, write a statement using ptr that is equivalent to the statement array[4] = 12;
  4. If ptr is a pointer to a character array called text, what array element is referenced by the statement x = *(ptr+5);?

Explanation / Answer

1.) char name[10];

char *nameptr = name;

2.) nameptr = &name[3];

3.) *(ptr + 16) = 12;


4.) 6th element will be referenced by "x=*(ptr+5);"