Sunday, January 10, 2010

Which one of the following statements could replace the ???? in the code above to cause the string 1-2-3-10-5- to be printed when the code is executed?

int x[] = {1, 2, 3, 4, 5};
int u;
int *ptr = x;
????
for( u = 0; u < 5; u++ ) { printf("%d-", x[u]); } printf( "\n" ); a) *ptr + 3 = 10; b) *ptr[ 3 ] = 10; c) *(ptr + 3) = 10; d) (*ptr)[ 3 ] = 10; e) *(ptr[ 3 ]) = 10;

No comments: