C Array Test 4


16) What is 'y' in the below program?

  1. 'x' is an array of three pointers
  2. 'x' is an array of three function pointers
  3. 'x' is a pointer
  4. Error in 'x' declaration

The correct option is (b).

Explanation:

The statement typedef char (*(*arrfptr[4])())[20]; means arfptr is an array of 3 function pointer which will return an array of 20 dimension whose data type is char.

Therefore 'x' is an array of three function pointers.

17) The return keyword is used for transfer control from a function back to the calling function.

  1. Yes
  2. No

The correct option is (a).

Explanation:

In C, the return function stops the execution of function and returns the control with value to the calling function. Execution is begins in calling function by instantly following the call.

18) What will be the output of the below program?

  1. 4 4 garbage value
  2. 4 4 0
  3. 4 4 4
  4. Compile error

The correct option is (c).

Explanation:

The two possible methods of accessing structure elements using pointer is by using * or -> (arrow operator).

Therefore the output of a program is 4 4 4.

19) What will be the output of the below program?

  1. 1
  2. 2
  3. 0
  4. Compile error

The correct option is (d).

Explanation:

In the program invalid syntax is used for initializing the array. Therefore compile error occurs in the output of a program.

20) Find out whether both the loops in a program prints the correct string length?

  1. Yes, both the loops prints the correct string length
  2. Only while loop prints the correct string length
  3. Only for loop prints the correct string length
  4. Compile error in the program

The correct option is (c).

Explanation:

In while loop the incorrect string length is printed because while loop variable 'i' get incremented after checking for '\0', hence giving 1 more than the length of string.

Therefore only for loop prints the correct string length.





Latest Courses