C programming interview questions

C programming interview questions | Freshers & Experienced

  • Pradeep
  • 03rd Dec, 2019

C Programming Interview Questions

Q1. What is difference between Stack and Queue?

A stack comprises of an impressionistic data type, constituted by physical stacks of units where addition and removal occur at the very same end. It is built on the LIFO principle that indicates last-in-first-out. The object might be figured up solely at a moment, or the object may be deleted which has been lastly added. A single pointer is utilized in the stack. Push and Pop, adds and removes newly added entities from a stack respectively. Stacks are envisioned as a vertical body. Like a pack of plates at a party.

However, a queue is opened at either end. It is built on the FIFO principle, which indicates first-in-first-out. Here you may only remove the first added entity. Duplet pointers are utilized here. Enqueue, dequeue add and removes entities to the stern and from the forepart of a queue respectively. Queues are horizontal. E.g. waiting for a mode of transport.

Q2. What is c preprocessor?

CPP or C pre-processor is a macro pre-processor for the C++ and C programming languages. A pre-processor offers the facility to include macro expansions, header files, line control, and conditional compilation. C preprocessor is simply a text replacing tool, which guides the compiler to perform the needed pre-processing earlier than the real compilation. It extends the horizon of a programming condition. Hence, its commands change the actual code in accordance with the operating condition and sum up the code which might be needed to library functions by calls. It is easily maintained, portable and enhances the legibility of C programming.

C Preprocessor

Q3. What is hashing in C language?

Q4. Explain huge pointer in c?

Q5. What is null pointer in c?

Q6. What is the use of pointers?

Q7. What is assert() in C?

Assert in C is a macro that checks the specific locations at runtime. Assert() is useful for debugging a program while it is still under execution. To use assert, "assert.h" must be included in the header file program. It is a statement to test the assumptions made by a programmer. Assert also checks if the pointer the malloc() return is null or not.

Assertions are run to check the impossible situations that are logically unfeasible to exist. They are completely disabled during runtime.

Q8. How can we convert integers to binary in C?

Q9. Are pointers are faster than arrays?Explain?

Q10. How can we clear the screen in C?

Q11. How to read single character in C?

Q12. What is "Hungarian Notation"?

Hungarian Notation happens to be an identifier denominating accord in computer coding or programming, where the denomination of a function or variable specifies its kind or intention and in imperceptible dialects its nature. It was devised to be dialect independent, eventually, it is utilized in the BCPL programming language. As BCPL, has negligible data types excluding the machine command, there is not a thing in the dialect that can aid programmer recollect variables’ types. Thus, Hungarian Notation's objective solves the problem by offering a programmer with the plain and direct command of every variable's data kind.

To simply put, Hungarian Notation being an anonym convention permits the programmer to control the variable’s types only by a glimpse at its denomination.

Q13. What is Dangling pointer?

Dangling Pointers emerges in the course of object destruction. When a target's incoming reference has been deallocated or deleted sans enhancing the pointer's evaluation, consequently the pointer nonetheless points towards the memory site of the obliterated memory. It can be also said that any pointer which contains no valid address or denotes a wrecked object is known as the Dangling Pointer.

Generally, Dangling Pointers are the outcome of use-after-delete, although it may also develop from yielding a stacked object’s address and utilizing it later when the stack structure has expired.

Q14. What is use of sizeof in C?

Q15. How to find memory leak in C?

Q16. What is size of void pointer?

Q17. What is the far pointer in c?

Q18. What are binary trees?

Q19. What is auto keyword in C?

C programming language has an auto keyword that describes a storage class of local variables inclusive of limited or local lifetime taken from the declaration of its edge to the enclosing scope's (function or block ); as program flow leaves that scope, the variable’s detail discontinue to exist.

An auto keyword indicates that the variable’s kind that in actuality stated will be undoubtedly subtracted against its initializer. For functions, if the return type of them is auto, then such will be assessed through return type language at runtime.

Q20. What is l-value and r-value?

Q21. What is a segmentation fault?

Q22. What is the output of below code in C: y = 4 || -1 && 0?

Q23. What is a scope resolution operator in C ?

Q24. What is the use of extern in C?

The keyword "extern" is utilized to enhance the clarity of variable or function. The functions are by default discernible all through the program. There is no obligation to define or declare extern functions. It only escalates the redundancy. Variables including extern keywords are not defined but solely declared.

It shows that a variable stated in one C programming file can further be utilized in another C programming file when you are compiling together the two files. Extern keyword being a modifier can be utilized with all types of data such as float, double, int, pointer, structure, function, and array, etc. Extern keyword is the default repository class of entire functions and global variables.

Hence you may utilize an extern when you desire to utilize a variable that indeed is stated in some different module with that you are linking.

Q25. What are Derived data types in C ?

Aggregation of data type that is fundamental in nature is known as derived data. Derived data types include arrays, unions, structures, enumeration, and pointers. The data are defined by the user just like defining a class in a structure or C++. Pointers store the address of the variables in the data. Array stores related type of data. Structure helps to place different types of items into single type groups.

Derived data types are a structure where all the members are in union and share the same location of memory.

Q26. What are bit fields in C ?

Q27. What is bit masking in C?

Masking is an act of applying a mask to a random value. A bit masking help to identify which bits are necessary and which bits are not. Bit masking is accomplished by applying:

  • To take out a subset of the bits in the value-Bitwise ANDing
  • To put a subset of the bits in the value-Bitwise ORing
  • To pin a subset of the bits in the value-Bitwise XORing

Application of mask to the value means clearing the first 4 bits and keeping the last 4 bits. By using the operators & and >>, high order bits inside a word as a first byte can be defined. In other words, bit masking means changing or keeping or removing a preferred information part.

About Author :

  • Author of C programming interview questions

    Pradeep Kumar

    Pradeep Kumar is proficient python programmer with experience in different technologies like Python Django, Scrapy, Angular JS and others languages. He have also worked on customization of test automation using Katalon Studio based on Groovy Language.

Leave A Comment :

Valid name is required.

Valid name is required.

Valid email id is required.