{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# 2_Answers_9 - CIS 15BG Questions Chapter 9 Pointers 1 1...

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

CIS 15BG Questions Chapter 9: Pointers 1. Given the following definitions, what is the type of the corresponding expressions? Definition Expression Type? int **p; **p int float ****q; ***q float * char ****r; &r char ***** 2. What is wrong with the following program fragment? int *p; int num; // p not initialized! p = &num; scanf( "%d", p ); 3. Given the following declarations: int x; char y; int *ptr1; char *ptr2; which of the following statements are not allowed? Why? a. x = y; // OK b. ptr1 = ptr2; // int * is different from char * c. ptr1 = &x; // OK d. x = &ptr1; // int is different from int ** e. ptr2 = &x; // char * is different from int * 1

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

View Full Document
CIS 15BG Questions Chapter 9: Pointers 4. In the following program fragment show the configuration of the variables and the output. int a = 15 ; int b = 5; int *p; int *q; int **r; int **s; p = &a; // p points to a q = &b; // q points to b r = &p; // r points to p s = &q; // s points to q *p = *p + 5; // 15 + 5 is assigned to a (*q)--; // same as b-- ; now b is 4 (**r)++; // same as a ++ ; now a is 21 *s = p; // change q to point to a printf( "% d % d % d % p ", *p, *q, **r, *s ); Write the correct format descriptors ( %d or
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

2_Answers_9 - CIS 15BG Questions Chapter 9 Pointers 1 1...

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

View Full Document
Ask a homework question - tutors are online