C Programming Interview Question and Answers for Placement


Are you going for interview then this article may useful for you. Because here we are giving some important technical question and answers for C language. As we know C language is most important language. When ever you go for interview the first question would C language. C language is basic programming language for computer science and engineering. Here i will share some most frequently question that may be asked in interview. We always thought that we know everything but before going to interview we should recall all topics than only we can reply to them. When you prepared each and everything you may get more confidence. That’s why here i am providing some important questions and answers for c language.  

C  Programming Interview Question and Answers for Placement

  1. What are the C tokens?

Ans. There are Six Classes of tokens: Identifier, Keywords, Constants, Strings, Literals, Operators and separator.

  1. What is C Identifier?

Ans. These are names given to various programming elements such as variables, functions, arrays. It is a combination of letter. Back space is not allowed.

  1. What is the difference between syntax error and Logical error?

Ans.  Syntax error: –  These involves Validation of syntax of language compliers prints diagnostic message.

Logical Error:- Logical error are caused by an incorrect algorithm by a statement mis- typed  in a such a way that difference.

  1. What are the facilities provided by pre processor?

Ans. File inclusion, substitution facilities, conditional compilation.

  1. What do the functions like atoi(), itoa(), gevt() ?

Ans.  Atoi() is a macro that converts integer to character.

Itoa() is converts integer to string

Gevt() it converts a floating point number to string.

  1. What is a file?

Ans. A file is a region of storage in hard disks or in auxiliary storage devices. It contains bytes of information it is not a data type.

  1. What is a function?

Ans.  A large program is subdivided into a number of smaller programs or subprograms. Each sub programs specifies one or more actions to be performed for the larger programs. Such sub programs are called functions.

  1. Difference b/w formal arguments and actual arguments?

Ans. Formal arguments are the arguments available in the function definition. They are preceded by their own data types. Actual arguments are available in the function call. These arguments are given as constants or variables or expressions to pass the values to the functions.

  1. What are the uses of a pointer?
  • It is used to access array elements
  • It is used for dynamic memory allocation
  • It is used in data structures like trees, graph, linked list ect.
  • It is used in call by reference.
  1. What is storage class? What are the different storage classes in C?

Ans. Storage class is an attribute that changes the behavior of a variable. It controls the lifetime, scope and linkages. The storage classes in c are auto, register, and external static, type def.

  1. Differentiate b/w a for loop and a while loop?

Ans. For Executing a set of statements fixed number of times we use for loop while when the number of iterations to be. Performed is not known in advance we use while loop.

  1. What is enumeration?

Ans. They are list of named integer- valued constants. Example:- enum color{black, orange=4,y,g, b, v}, the difference b/w an enumeration and a macro is that the enum actually declares a type and therefore can be type checked.

  1. What are static memory allocations?

Ans. Compiler allocates memory space for a declared variable. By using the address of operator, the reserved address is obtained and this address is a signed to a pointer variable. This way of assigning pointer value to a pointer variable at compilation time is known as static memory allocations.

  1. What is dynamic memory allocation?

Ans.   A dynamic memory allocation uses functions such as malloc() or calloc() to get memory dynamically. If these functions are used to get memory dynamically and the values returned by these functions are assigned to pointer variables, such a way of allocation memory at run time is known as dynamic memory allocations.

  1. Difference b/w pass by reference and pass by value?

Ans. pass by reference passes a pointer to the value. This allows the calloc to modify the variable directly pass by value gives a copy of the value to the calloc. This allows the calloc to modify the value without modifying the variable.

  1. What are library functions?

Ans. Library functions are predefined functions and stored in .lib files

  1. What is structure?

Ans. Structure is a collection of heterogeneous held together to a single unit. The data items enclosed within A Structure are called it’s members which may be of data type int, float, char, array ect.

  1. What is the difference between arrays and linked list?

Ans. Major Difference between arrays and linked lists are in array consecutive elements are stored in consecutive memory locations where as in linked list it not so. In array address of next element is consecutive and where as in linked list it is specified in the address part of each mode. Linked list makes better use of memory in array. Insertion or deletion of an element in array is difficult than insertion or deletion in liked list.

  1. Where are the auto variables stored?

Ans. Auto variables are stored in main memory and their default value is a garbage value.

  1. What is the use of typedef?

Ans. It increase the portability. It simplify the complex declaration and improve readability of the program.

  1. Why n++ executes faster than n+1 ?

Ans. The expression n++ requires a single machine instruction such as INR to carry out the increment operation whereas, n+1 requires more instructions to carry out this operation.

  1. What is dangling pointer in c?

Ans.  If any pointer is pointing the memory address of any variable but after some variable has deleted from that memory location while pointer is still pointing such memory location. Such pointer is known as dangling pointer and this problem is known as dangling pointer and this problem is known as dangling pointer and this problem is known as dangling pointer problem.

23.  What is a pointer?

Ans. Pointer is a variable that contains address of another variable in the memory. Pointers are quite useful in creation of linked data structures (such as linked list, trees, graphs), managing object allocated memory dynamically, optimize the program to execute faster and use less memory.

24. What are the techniques you use for debugging?

Ans. Using compiler’s features , read the fine module, printf() debugging. Code grinding, assertion.

25. What are macros? What are its advantages and disadvantages?

Ans. Macro is a pre-processor. A major advantage of using the macro is to increase the speed of the execution of the program. Disadvantage of the macros are no type checking is performed in macro. A macro call may cause unexpected results.

26. What are segment and offset addresses?

Ans. When paging technique is performed, the page will break into segments and it’s sequence is said to be segments and its  width can be said to be said as offset, in short segment is physical addresses and offset is logical address.

27.  How many types of scope in c ?

Ans. There are totally four scopes are block scope, function scope, file scope, program scope.

28. what is the difference between calloc () and malloc ()?

Ans. Calloc () allocates a block of memory for an array of elements of certain size. by default the block is initialized too. the tatal number of memory allocated will be number of elements*size.

Malloc () takes in only a single arguments which is the memory required in bytes, malloc allocated bytes of memory and not blocks of memory like calloc ().

Now do not even bother about any topic. We have covered all topics for c language. These questions and answers are most frequently asked in interview. Just prepared well and crack the interview. Do not think about anything just be confident.

Leave a Reply