Javatpoint Logo
Javatpoint Logo

C Pointers Test 4


16) What will be the output of the program given below?

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

The correct option is (c).

Explanation:

In the program x points the NULL address. It is invalid to access the NULL address hence the program gives Runtime error.

Therefore the output of the program is Runtime error.

17) Is this a right way for NULL pointer assignment?

  1. Yes
  2. No

The correct option is (b).

Explanation:

The above null pointer assignment method is incorrect.

The correct way is:

18) Will the program be compiled in Turbo C?

  1. Yes
  2. No

The correct option is (b).

Explanation:

In statement p++ error occur because we cannot perform arithmetic operation on void pointers.

The following error is display on compiling the above program in TurboC.

Compiling PROGRAM.C:

Error PROGRAM.C 8: Size of the type is unknown or zero.

19) Which statement is correct about the program given below?

  1. j is a pointer to an int and stores address of i
  2. i is a pointer to a pointer to an int and stores address of j
  3. i and j are pointers to an int
  4. i is a pointer to an int and stores address of j

The correct option is (d).

Explanation:

In program 'i' is the variable contain pointer. So it is pointer variable and points toward an integer type in memory location. Therefore 'i' is a pointer to an int.

Now the address of 'j' is assigned to the 'i' pointer, i.e. address of 'j' store to 'i' location.

Therefore the 'i' is a pointer to an int and it stores the address of 'j'.

20) What will be the output of the program given below?

  1. Xyz
  2. yz
  3. Runtime error
  4. Compile error

The correct option is (a).

Explanation:

In program while loop continues until *s is not equal to '\0'. Inside loop character is fetched first and address is incremented later.

Therefore the print statement i.e. printf("%c", *p++); will print the Xyz in output.






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