Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What will be the output of the program if the size of pointer is 4-bytes?

Answer» In TurboC, the output will be 2, 1 because the size of the pointer is 2 bytes in 16-bit platform. But in Linux, the output will be 4, 1 because the size of the pointer is 4 bytes. This difference is due to the platform dependency of C compiler.
2.

Are the expression and are same?

Answer» *ptr++ increments the pointer and not the value, whereas the ++*ptr increments the value being pointed by ptr
3.

Point out the compile time error in the program given below.

Answer» While reading the code there is no error, but upon running the program having an unitialised variable can cause the program to crash (Null pointer assignment).
4.

Will the program compile?

Answer» C doesn't do array bounds checking at compile time, hence this compiles. But, the modern compilers like Turbo C++ detects this as 'Error: Too many initializers'. GCC would give you a warning.
5.

Is this a correct way for NULL pointer assignment?

Answer» The correct way is char *q=0 (or) char *q=(char*)0
6.

Will the program compile in Turbo C?

Answer» Error in statement k++. We cannot perform arithmetic on void pointers. The following error will be displayed while compiling above program in TurboC. Compiling PROGRAM.C: Error PROGRAM.C 8: Size of the type is unknown or zero.
7.

In which header file is the NULL macro defined?

Answer» The macro "NULL" is defined in locale.h, stddef.h, stdio.h, stdlib.h, string.h, time.h, and wchar.h.
8.

How many bytes are occupied by and pointers (DOS)?

Answer» near=2, far=4 and huge=4 pointers exist only under DOS. Under windows and Linux every pointers is 4 bytes long.