1_Answers_ArraysAndPtr_10

1_Answers_ArraysAndPtr_10 - CIS 15BG 1 Answers Chapter 10:...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CIS 15BG Answers Chapter 10: POINTER APPLICATIONS: Pointers and Arrays 1. Why are pointers important? (A). Pointers are used in functions for reference parameters. (B). Pointers provide efficient techniques for manipulating data in arrays. (C). Pointers are the basis for dynamic allocation of memory. 2. (A) What does function fun do? Reverses a list of characters in place (B) What does word contain after the call? Before: stressed After : desserts (C) Change this function using pointers instead of indices. Cross and replace a statement or modify an existing statement (do not rewrite everything!) 1 . . . char word[8] = {'s', 't', 'r', 'e', 's', 's', 'e', 'd'}; int size = 8; fun( word, word + size - 1 ); . . . /* ============================== */ void fun( char *first, char *last ) { char temp; while( first < last ) { temp = *first; *first = *last; *last = temp; first++; last--; } return; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CIS 15BG Answers Chapter 10: POINTER APPLICATIONS: Pointers and Arrays 3. An array contains mid-term exam scores. Write a function that counts the number of
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

1_Answers_ArraysAndPtr_10 - CIS 15BG 1 Answers Chapter 10:...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online