Top 45 C programming interview questions and answers

31 What are different ways to declare constants in C?

Constants can be declared using the keyword const and using the #define preprocessor.

32) What is type casting?

Type casting is to convert one data type into another. In C we have two categories:

  1. Implicit type casting done by compiler
  2. Explicit type casting done by user
33) What is meant by modular programming?

By modular programming we mean to divide the whole program (problem) into small modules by defining functions. The program becomes reusable by dividing it into modules.

34) How can you declare functions in C?

A function can be declared by specifying the return type of the function and then the name of function with function arguments within parenthesis. The following is how you can declare function in C:

returnTypefunctionName(argument1, argumentN);

For example:

int add(int a, int b); //This is the declaration of function ended with semi colon.

35) How can you call your function? Describe some different ways to call a function?

A function can be called using its name and passing values for arguments (if any). In C we can call a function in assignment statement (if it returns a value), in printf statement (if it returns a value). If the function doesn’t return a value you can simple call the function using its name and passing arguments.


36) What is difference between function declaration and function definition? What is prototype of a function?

Function declaration also called function prototype is used to declare a function and is ended with a semi colon whereas, function definition is to define the body of the function or define the behavior or functionality of the function.

37) How a function can be called by reference?

When calling function by reference you are passing addresses of values to the formal parameters. This address is then used by function to perform specific task. Consider the example below:

int add (int *a, int *b)

Here *a, *b are the pointers holding addresses of the corresponding values or variables.

38) What is meant by recursive call?

A function calling itself is called a recursive function and this process is known as recursion or recursive call. A function can call itself inside its definition.

39) What is difference between pointer and a regular variable?

A pointer holds the address of the variable whereas a regular variable holds a value and is a named memory location to hold some value.

40)Explain dangling Pointer in C.

A dangling pointer is the one which points to the deleted memory location. Dangling pointer occurs when an objected is destroyed and the memory is de-allocated but the pointer is still pointing to the freed memory

41) What is the use of library functions in C?

Library functions are the built in or primitive functions defined at the time of manufacturing. These functions have specific tasks to perform for example printf() statement can be used to display output on the output screen. To use the library functions you have to include respective header files for example stdio.h for printf().

42) What is an auto variable?

An auto variable is a local variable. When you declare a variable as automatic it will be allocated memory at the beginning of the execution of the program and memory will be de allocated when the execution is done.

43) What is meaning of e in getche() function?

What is meaning of e in getche() function? The e in getche() stands for echo. When the user enters any character in output screen, it is displayed on the output screen or echoes on the output screen without waiting for the enter key to be pressed. The getche() function is included in the header file conio.h.

44) What are the different errors that can be occurred in your C program?

In C program, we can have syntax error because of wrong syntax, run time error also called exception that can be occurred for example multiplying any number by zero, and then we have logical errors that are the type of run time errors.

45) What do you mean by enumeration in C?

Enumeration is used to assign strings to integral constants. Enumeration is a user defined data type which can be created by using the enum keyword.


« 1 2 3 »  

Popular Posts


Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer & technology lovers.