Javatpoint Logo
Javatpoint Logo

C Array Test 2


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

  1. 100
  2. 200
  3. 101
  4. 201

The correct option is (c).

Explanation:

In program *x refers to 100 and adding a 1 to *x gives 101.

Therefore the output is101.

7) In the below statement, what does the "arr" indicates?

  1. arr is an array of 20 characters
  2. arr is an array of 20 character pointers
  3. arr is an array of function
  4. arr is a pointer to an array

The correct option is (b).

Explanation:

The Square parenthesis signifies an array at declaration and the type is char *. So it is an array of character pointer.

Therefore "arr" is an array of 20 character pointers.

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

  1. C++ ++
  2. ++ ++
  3. C++ C++
  4. Compile error

The correct option is (d).

Explanation:

In program 'a' refers to constant address and the constant address variable is not allowed to be incremented.

Therefore the program will generate compile error in output.

9) Which of the statements are correct about 5 used in the program?

  1. In the first statement 5 specifies an array size, whereas in the second statement it specifies a particular element of array.
  2. In the first statement 5 specifies a particular element, whereas in the second statement it specifies a array size.
  3. In the first statement 5 specifies a particular element, whereas in the second statement it specifies a type.
  4. In both the statement 5 specifies array size.

The correct option is (a).

Explanation:

The statement int num[5]; specifies the size of array and num[5]=20; specifies the particular element (6th element) of the array.

Therefore in first statement 5 specifies an array size, whereas in second element it specifies a particular element of an array.

10) Which of the below statements using the name of an array does not yield the base address?

  1. When array name is operand of the & operator
  2. When array name is passed to scanf() function
  3. When array name is passed to printf() function
  4. When array name is used with the sizeof operator.
  1. 1, 4
  2. 4
  3. 1
  4. 1, 3

The correct option is (a).

Explanation:

The statement 1 and 4 does not yield the base address of an array. While the printf() and scanf() yields the base address of an array.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA