C Programming Interview Questions

Q21.   What is MACRO ?

  • Macro is a name which is given to a value or to a piece of code/block in a program.

  • Instead of using the value, we can use macro which will replace the value in a program at compile time.

Q22.   What is POINTERs in C ?

  • Pointer is a variable that stores/points the address of another variable.

  • Pointer is a variable that stores/points the address of another variable.

Q23.   Explain & and * operators for POINTERs ?

  • "*" Operator is used as pointer to a variable. Example: int *a where * represents a is pointer variable.

  • "&" operator is used to get the address of the variable. Example: &a will give address of a.

Q24.   What is void POINTER ?

  • void pointer is a generic pointer that can be used to point another variable of any data type.

void *ptr1, *ptr2;
int   x = 40;
float y = 30;
ptr1 = &x;
ptr2 = &y;

Q25.   What is NULL POINTER ?

  • NULL pointer is a pointer which is pointing to nothing.

  • NULL pointer points to empty location in memory.

  • Value of null pointer is 0.

  • We can make a pointer to point to null as below.
    int *p = NULL;

Q26.   What is dangling POINTER in C ?

  • When a pointer is pointing to non-existing memory location is called dangling pointer.

Q27.   What is wild POINTER in C ?

  • Uninitialized pointers are called as wild pointers in C which points to arbitrary (random) memory location.

  • This wild pointer may lead a program to behave wrongly or to crash.

Q28.   What is FILE POINTER in C ?

  • File pointer is a pointer which is used to handle and keep track on the files being accessed.

  • A new data type called FILE is used to declare file pointer.

  • This data type is defined in stdio.h file.

  • File pointer is declared as FILE *fp. Where, fp is a file pointer.

Q29.   What is the size of int and char pointers ?

  • Pointer variable size is not depending on data type as pointer always stores the address of other variable which is always integer data type.

  • So, any pointer (int, char, double, etc) size will be 2 for 16 bit processor, 4 for 32 bit processor and 8 for 64 bit processor.

  • sizeof() operator can be used to evaluate size of a variable/pointer in C.

Q30.   What is the difference b/w ARRAY and POINTER variable ?

  • Array is a collection of variables belongings to the same data type.

  • Array variable holds the base address i.e the address of first element of array.

  • The size of array variable is : size_of_type * array_size.
    float a[5];
    the sizeof(a) will be 4*5 = 20

  • Pointer is a single variable that stores the address of other object/variable.

  • The size of pointer variable is : size_of_int
    float *a;
    the sizeof(a) will be 4(16 bit) or 2(16 bit)

Q31.   What is the difference between Call by Value and Call by Reference ?

  • When using Call by Value, you are sending the value of a variable as parameter to a function, whereas Call by Reference sends the address of the variable.

  • Also, under Call by Value, the value in the parameter is not affected by whatever operation that takes place, while in the case of Call by Reference, values can be affected by the process within the function.

Q32.   What is memory leak in C ?

  • Memory leak occurs when memory is allocated but not released back to the operating system.

  • Memory leakage increases unwanted memory usage. So, it reduces performance of the computer by reducing available memory.

Q33.   What is memory/segmentation fault in C ?

  • Segmentation fault is a fault that occurs because of illegal/invalid memory access.

  • Illegal memory access means, When a program tries to access a memory location that is not allowed or when a program tries to access a memory location in a way that is not allowed.

Q34.   What are TOP-DOWN and BOTTOM-UP programming approach ?

  • Top down approach and bottom up approach are involved in software development. These approaches are not involved in program execution.

  • Structure/procedure oriented programming languages like C programming language follows top down approach.

  • Whereas object oriented programming languages like C++ and Java programming language follows bottom up approach.

  • Top down approach begins with high level design and ends with low level design or development. Whereas, bottom up approach begins with low level design or development and ends with high level design.

  • In top down approach, main() function is written first and all sub functions are called from main function.

  • Then, sub functions are written based on the requirement. Whereas, in bottom up approach, code is developed for modules and then these modules are integrated with main() function.


(8AM to 10PM):

+91-8527238801 , +91-9451396824

© 2017,, All rights reserved