Classical

C Programming MCQ - Pointers

21:  

Consider the declarations
char first (int (*) (char, float)) ;
int second(char, float);

Which of the following function invocation is valid?

A.

first (*second) ;

B.

first (&second);

C.

first (second);

D.

none of the above

 
 

Option: C

Explanation :


22:  

 A function q that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as

A.

int (*q (char*) )[ ] 

B.

Int *q(char *)[ ] 

C.

int (*q) (char *)[ ] 

D.

none of the above

 
 

Option: A

Explanation :

Function Input : 'Pointer to a character'.

For example : Pointer to a character will be represented as "char * Y" which will signify (Y is a pointer to character)

Similarly in this case, a general argument notation would be "char *"

Function Output : 'Pointer to an array of integers'.

For example : Pointer to an array of integers will be represented as "int(*Z)[10]" which will signify (Z is a pointer to an array of integers)

Similarly in this case, a general argument notation would be "int(*)[]"

Function Name : 'q'.

Now, in this case when we combine the input, output and function name, the function representation will becomes 

int (*q (char*) )[ ]

This will hence signify that the function takes an input as pointer to a character and returns pointer to an integer array.


23:  

 Let x be an array. Which of the following operations are illegal?

A.

++x

B.

x * 2

C.

x++

D.

All of these

 
 

Option: D

Explanation :


24:  

If func is a function needing three arguments a1, a2,  a3 then func can be invoked by

A.

 func(a1, a2, a3) ;

B.

(*func)(a1, a2, a3);

C.

*func(a1, a2, a3);

D.

both (a) & (b)

 
 

Option: D

Explanation :


25:  

The declaration
int (*p) [5];
means

A.

p is a one dimensional array of size 5, of pointers to integers

B.

p is a pointer to a 5 element integer array

C.

the same as int *p[5];

D.

none of the above

 
 

Option: B

Explanation :




Suggest an improvement