Classical

C Programming MCQ - Pointers

11:  

Consider the following program fragment.
static char wer[3][4] = {"bag", "let", "bud"};
char(*ptr)[4] = wer;

The putchar (* (wer [1] + 1)) ;

A.

prints e

B.

prints a

C.

prints 1

D.

prints b

 
 

Option: A

Explanation :


12:  

Consider the following program fragment.
static char wer[3][4] = {"bag", "let", "bud"};
char(*ptr)[4] = wer;

The possible output of printf ( "%d %d", wer, wer +1); is

A.

262 262

B.

262 266

C.

262 263

D.

262 265

 
 

Option: B

Explanation :


13:  

The operators > and < are meaningful when used with pointers, if

A.

the pointers point to data of similar type

B.

the pointers point to structure of similar data type

C.

the pointers point to elements of the same array

D.

none of these

 
 

Option: C

Explanation :


14:  

Choose the best answer. Prior to using a pointer variable

A.

it should be declared

B.

it should be initialized

C.

it should be both declared and initialized

D.

none of the above

 
 

Option: C

Explanation :

using a pointer variable without intializing it, will be disastrous, as it will have garbage values


15:  

Consider the two declarations
void *voidPtr;
char *charPtr;

Which of the following assignments are syntactically correct?

A.

voidPtr = charPtr

B.

charPtr = voidPer

C.

*voidPtr = *charPtr

D.

*charPtr = voidPtr

 
 

Option: A

Explanation :




Suggest an improvement