{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Fall 2002 - page 1 of 3 Fall 2002 Consider the following...

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

View Full Document Right Arrow Icon
page 1 of 3 Fall 2002 Consider the following declarations: double one[10]={1.0,2.1,3.5,4.8,5.3,6.7,7.2,8.1,9.3,10.4}; double two[5][5],*ptr, value=1.0; 1.(12pts, 2 each) )Indicate whether each of the following statements would be valid or invalid, and if invalid, why. Consider each statement separately. a. two[3,0] = 25.3; invalid, need separate brackets: two[3][0] b. ptr = &one; invalid, one is a pointer constant, should not use & c. ptr = two[2]; invalid, ptr is pointer to double, two[2] is pointer to array of doubles d. value = two[3][5]; invalid, second subscript is out of bounds e. printf("%lf\n", two[1]); invalid, two[1] is a pointer not a double f. one = &two; invalid, one is a pointer constant which cannot be reassigned 2.(4pts, 1 each)Which of the following would reference the same value as two[1][3]? Circle all that are equivalent. a. two[4]; b. *(*(two+1)+3); c. *(*(two+3)+1); d. *(*two+8); unix produces warning but it works Consider the following declaration: char s1[16]="Rats", *s2 = "A1"; Indicate whether each of the following statements would be valid or invalid by circling those that are invalid. scanf("%s",&s1);
Background image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}