Write the statements to declare an array of 10 characters called name, declare a
ID: 3554892 • Letter: W
Question
- 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.
- Now declare nameptr and initialize it to point to the fourth element of name.
- 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;
- 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);"
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.