Interview Questions.

Top 100+ C & Data Structures Interview Questions And Answers

fluid

Top 100+ C & Data Structures Interview Questions And Answers

Question 1. What Is C Language?

Answer :

C is a programming language used to jot down a software. Programs are the set of commands given by a programmer to the pc in excessive degree language. C makes use of a compiler to translate the excessive degree software into gadget code earlier than executing any guidance.

Question 2. What Does Static Variable Mean?

Answer :

Static variable is available to a C application, throughout the lifestyles time. At the time of starting this system execution, static variables allocations takes area first. In a scenario where one variable is to be utilized by all the capabilities (that is accessed by way of fundamental () function), then the variable want to be declared as static in a C program.

C Interview Questions
Question three. What Is The Difference Between Calloc() And Malloc() ?

Answer :

A block of memory may be allotted using the function malloc. The malloc feature reserves a block of reminiscence of precise length and returns a pointer of type void. This method we can assign the base deal with of the block to any form of pointer.
  Syntax –     P = (cast type*)malloc(byte size);
Calloc is also a reminiscence allocation function that's commonly used to allocate memory for array and shape .Malloc is used to allocate a single block of garage area, calloc allocates more than one blocks of garage, every of same length and initializes them with 0.
  Syntax -     P = (cast type*)calloc(n,array size);

Question four. What Is A Null Pointer?

Answer :

A null pointer is a special pointer value this is known now not to factor everywhere. It manner that no other legitimate pointer, to any other variable or array mobile or anything else, will ever evaluate equal to a null pointer.

C Tutorial
Question five. Advantages Of A Macro Over A Function?

Answer :

Actually macro and characteristic are used for specific functions. A macro replaces its expression code physically in the code at the time of preprocessing. But in case of characteristic the control is going to the characteristic even as executing the code. So while the code is small then it's miles higher to use macro. But whilst code is massive then feature ought to be used.

JSTL(JSP Standard Tag Library) Interview Questions
Question 6. What Is Page Thrashing?

Answer :

It happens when a excessive stage of paging pastime. Thrashing is caused by under allocation of minimum range of pages required via a method, forcing it to continuously web page fault. 

Question 7. How Do You Override A Defined Macro?

Answer :

You can use the #undef preprocessor directive to undefined (override) a formerly described macro.

Data Structure & Algorithms Tutorial Database Administration Interview Questions
Question 8. What Are The Different Storage Classes In C?

Answer :

C has 3 types of storage: computerized, static and allocated. Variable having block scope and with out static specifier have computerized storage length. Variables with block scope and with static specifier have static scope. Global variables (i.E., file scope) without or with the static specifier also have static scope. Memory acquired from calls to malloc(), alloc() or realloc() belongs to storage magnificence.

Question 9. When Does The Compiler Not Implicitly Generate The Address Of The First Element Of An Array?

Answer :

Whenever an array call appears in an expression including
• Array as an operand of the sizeof operator.
• Array as an operand of “&” operator.
• Array as a string literal initializer for a man or woman array.
Then the compiler does now not implicitly generate the cope with of the address of the primary element of an array.

Computer structure Interview Questions
Question 10. Is Using Exit () The Same As Using Return?

Answer :

No, The go out () characteristic is used to go out your software and return manage to the operating device.The go back announcement is used to go back from a feature and go back manipulate to the calling characteristic. If you difficulty a return from the principle () function, you're essentially returning manage to the calling characteristic, that is the running device. In this situation, the go back declaration and exit () function are comparable.

Question 11. What Do You Mean By Dynamic Memory Allocation? Give An Example.

Answer :

The method of allocating memory on the time of execution is called dynamic memory allocation. The allocation and launch of this memory area may be executed with the help of some constructed in features whose prototypes are observed in alloc.H and stdlib.H.
Example:-
#encompass<stdio.H>
#encompass<alloc.H>
essential()

int *p, n, i;
printf( “Enter the quantity of integers to be entered.”);
scanf(“%d”, &n);
p=(int *)malloc(n*sizeof(int));
if(p==NULL)

printf(“Memory now not to be had”);
go out(1);

for(i=0;i<n;i++)

printf(“Enter an integer”);
scanf(“%d”, p+1);

for(i=zero;i<n;i++)
printf(“%d”, *(p+i));

return 0;


 

IDMS (Integrated Database Management System) Interview Questions
Question 12. How Do You Construct An Increment Statement Or Decrement Statement In C?

Answer :

There are really two ways you may do this. One is to use the increment operator ++ and decrement operator –. For instance, the declaration “x++” means to increment the price of x with the aid of 1. Likewise, the announcement “x –” manner to decrement the value of x with the aid of 1. Another way of writing increment statements is to use the conventional + plus signal or – minus sign. In the case of “x++”, some other manner to write it is “x = x +1”.

C Interview Questions
Question thirteen. What Is The Difference Between Call By Value And Call By Reference?

Answer :

When the use of Call with the aid of Value, you're sending the value of a variable as parameter to a characteristic, while Call via Reference sends the address of the variable. Also, below Call by Value, the fee in the parameter isn't always suffering from anything operation that takes location, even as in the case of Call with the aid of Reference, values may be tormented by the procedure inside the function.

Question 14. Some Coders Debug Their Programs By Placing Comment Symbols On Some Codes Instead Of Deleting It. How Does This Aid In Debugging?

Answer :

Placing comment symbols /* */ round a code, additionally referred to as “commenting out”, is a manner of separating a few codes that you assume maybe inflicting mistakes within the application, without deleting the code. The concept is if the code is in fact correct, you surely remove the comment symbols and maintain on. It also saves you time and effort on having to retype the codes when you have deleted it within the first region.

 

Question 15. What Is A Stack?

Answer :

A stack is one form of a records structure. Data is stored in stacks using the FILO (First In Last Out) method. At any precise instance, only the top of the stack is on the market, because of this that so one can retrieve records this is stored within the stack, those at the top element need to be extracted first. Storing statistics in a stack is likewise referred to as a PUSH, at the same time as facts retrieval is known as a POP.

Data Structure & Algorithms Interview Questions
Question sixteen. What Is A Sequential Access File?

Answer :

When writing packages with the intention to save and retrieve records in a record, it's miles feasible to designate that record into distinct bureaucracy. A sequential get right of entry to report is such that information are saved in sequential order: one records is positioned into the report after another. To get admission to a particular records in the sequential get entry to document, facts must be examine one records at a time, until the proper one is reached.

Question 17. What Is Variable Initialization And Why Is It Important?

Answer :

This refers to the technique in which a variable is assigned an initial price before it's far used in the application. Without initialization, a variable might have an unknown value, that could lead to unpredictable outputs whilst utilized in computations or other operations.

 

Programming Algorithms Interview Questions
Question 18. What Is Spaghetti Programming?

Answer :

Spaghetti programming refers to codes that tend to get tangled and overlapped at some stage in the program. This unstructured method to coding is typically attributed to loss of enjoy at the a part of the programmer. Spaghetti programing makes a program complex and reading the codes difficult, and so ought to be avoided as much as viable.

JSTL(JSP Standard Tag Library) Interview Questions
Question 19. Differentiate Source Codes From Object Codes

Answer :

Source codes are codes that have been written by way of the programmer. It is made from the instructions and different English-like keywords which are purported to instruct the pc what to do. However, computers could now not be able to apprehend supply codes. Therefore, supply codes are compiled the usage of a compiler. The ensuing outputs are object codes, which might be in a layout that can be understood by means of the pc processor. In C programming, source codes are stored with the record extension .C, whilst object codes are stored with the file extension .OBJ

Question 20. In C Programming, How Do You Insert Quote Characters (‘ And “) Into The Output Screen?

Answer :

This is a commonplace trouble for novices because costs are generally part of a printf declaration. To insert the quote person as part of the output, use the layout specifiers ’ (for unmarried quote), and ” (for double quote).

Object Oriented Programming in PHP Interview Questions
Question 21. What Is The Use Of A ‘’ Character?

Answer :

It is called a terminating null man or woman, and is used typically to show the give up of a string cost.

Question 22. What Is The Difference Between The = Symbol And == Symbol?

Answer :

The = image is often used in mathematical operations. It is used to assign a cost to a given variable. On the opposite hand, the == image, additionally referred to as “identical to” or “equivalent to”, is a relational operator this is used to examine two values.

Question 23. What Is The Modulus Operator?

Answer :

The modulus operator outputs the remainder of a division. It makes use of the proportion (%) symbol. For example: 10 % 3 = 1, that means whilst you divide 10 by way of three, the the rest is 1.

Standard Template Library (STL) Interview Questions
Question 24. What Is A Nested Loop?

Answer :

A nested loop is a loop that runs inside some other loop. Put it in some other experience, you have got an inner loop that is inner an outer loop. In this situation, the inner loop is executed some of times as exact through the outer loop. For each turn on the outer loop, the internal loop is first done.

 

Database Administration Interview Questions
Question 25. Compare And Contrast Compilers From Interpreters.

Answer :

Compilers and interpreters regularly cope with how software codes are done. Interpreters execute application codes one line at a time, whilst compilers take the program as a whole and convert it into object code, earlier than executing it. The key difference right here is that in the case of interpreters, a program may additionally stumble upon syntax errors in the center of execution, and will prevent from there. On the alternative hand, compilers take a look at the syntax of the whole software and will handiest proceed to execution whilst no syntax mistakes are found.

Question 26. How Do You Declare A Variable That Will Hold String Values?

Answer :

The char key-word can simplest keep 1 man or woman price at a time. By growing an array of characters, you can save string values in it. Example: “char MyName[50]; ” broadcasts a string variable named MyName which can preserve a most of 50 characters.

Question 27. Can The Curly Brackets   Be Used To Enclose A Single Line Of Code?

Answer :

While curly brackets are specially used to group numerous traces of codes, it'll nonetheless paintings with out error in case you used it for a unmarried line. Some programmers choose this approach as a way of organizing codes to make it look clearer, mainly in conditional statements.

Computer architecture Interview Questions
Question 28. What Are Header Files And What Are Its Uses In C Programming?

Answer :

Header documents are also called library files. They comprise two crucial things: the definitions and prototypes of features being used in a software. Simply put, commands which you use in C programming are without a doubt capabilities which might be defined from within each header documents. Each header report consists of a hard and fast of functions. For example: stdio.H is a header document that contains definition and prototypes of instructions like printf and scanf. 

Question 29. What Is Syntax Error?

Answer :

Syntax errors are related to mistakes within the use of a programming language. It maybe a command that was misspelled or a command that need to turned into entered in lowercase mode but become instead entered with an top case person. A misplaced symbol, or lack of symbol, someplace within a line of code can also cause syntax errors.

Question 30. What Are Variables And It What Way Is It Different From Constants?

Answer :

Variables and constants may additionally in the beginning look comparable in a feel that each are identifiers made up of one man or woman or extra characters (letters, numbers and a few allowable symbols). Both may even maintain a particular price.  Values held by means of a variable can be altered during the program, and can be used in maximum operations and computations. Constants are given values at one time best, placed at the beginning of a program. This price isn't always altered within the program. For instance, you could assigned a constant named PI and deliver it a price three.1415  .  You can then use it as PI inside the software, as a substitute of getting to put in writing three.1415 each time you want it. 

Question 31. What Is Data Structure?

Answer :

Data structure is a collection of facts elements grouped together beneath one call.
These facts elements are called individuals. They can have different types and exclusive lengths.
Some of them keep the information of same type while others store distinct forms of information.
Question 32. Explain The Types Of Data Structures

Answer :

There are  simple kinds of data systems:

linear.
Nonlinear. 
Linear information systems : Linear data systems are prepared in a manner similar to the manner laptop memory is organized. Linear records structures store factors one after the other, in a linear fashion. Only one detail of the facts may be traversed at a time. Imagine a stack of books positioned on a shelf. A book could be placed among two other books, but now not three books- a e book will simplest have a relationship to 2 other books on the maximum at one time. Linear information elements are saved in a similar way.
Non linear statistics structures : Non linear information systems are saved in a sequential way. The statistics factors in the non linear statistics systems might also have relationships with one or greater factors on the equal time. Manipulating non linear records structures is greater difficult than manipulating linear information structures.

Question 33. List Out The Areas In Which Data Structures Are Applied Extensively?

Answer :

Compiler Design.
Operating System.
Database Management System.
Statistical evaluation bundle.
Numerical Analysis.
Graphics.
Artificial Intelligence.
Simulation.
IDMS (Integrated Database Management System) Interview Questions
Question 34. Differentiate File Structure From Storage Structure.

Answer :

Basically, the important thing difference is the memory area that is being accessed. When dealing with the shape that resides the primary reminiscence of the computer system, this is known as garage structure. When handling an auxiliary structure, we discuss with it as record structure.

 

Question 35. Which Data Structure Is Used To Perform Recursion?

Answer :

The facts shape used for recursion is Stack.
Its LIFO assets helps it recollects its 'caller'. This facilitates it recognize the information that's to be returned while the feature has to go back.
System stack is used for storing the return addresses of the function calls.
Question 36. What Is A Linked List?

Answer :

A related listing is a fixed of linear factors wherein every element has an index or a pointer that suggests the subsequent detail. An detail of a connected listing is referred to as a node. A node will shop information in addition to a pointer/index about the next node in the set. There are specific sorts of linked lists. For example, a round linked listing is a listing wherein the remaining element of the list points to the primary element of the list, forming an unbroken chain of statistics. A double related list is a list in which each node stores the index of the node on both side of it.

Data Structure & Algorithms Interview Questions
Question 37. What Are The Major Data Structures Used In The Following Areas ?

Answer :

 RDBMS, Network data version and Hierarchical data model.

RDBMS = Array (i.E. Array of structures)
Network records model = Graph
Hierarchical statistics model = Trees
Question 38. What Is Lifo?

Answer :

LIFO is short for Last In First Out, and refers to how statistics is accessed, saved and retrieved. Using this scheme, records that turned into saved final , should be the only to be extracted first. This additionally means that for you to gain get entry to to the first facts, all of the other information that become saved earlier than this first information need to first be retrieved and extracted.

Question 39. Does The Minimal Spanning Tree Of A Graph Give The Shortest Distance Between Any 2 Specified Nodes?

Answer :

No, it doesn’t.It assures that the overall weight of the tree is kept to minimal.It does not mean that the space between any two nodes worried inside the minimal-spanning tree is minimum.

Question forty. What Is A Queue?

Answer :

A queue is a set of data that follows the FIFO (First in First Out) precept. It is a type of a linear data shape. Elements in a queue are removed only from the front, while new elements are brought most effective at the back of a queue. Imagine a queue of humans in the front of film theater for tickets. People can’t bypass to the the front for tickets – they need to be a part of the back of the queue. People leave the queue simplest when they get their tickets, from the the front. This is a tremendous example of a queue in records structures. The  operations achieved on a queue are enqueue (adding information elements) and dequeue(removing information factors).
A precedence queue is a queue wherein every element in the queue is assigned a concern and operations are done on it according to this precedence.

Programming Algorithms Interview Questions
Question 41. If You Are Using C Language To Implement The Heterogeneous Linked List, What Pointer Type Will You Use?

Answer :

The heterogeneous connected list contains one of a kind records sorts in its nodes and we want a hyperlink, pointer to attach them. It is not feasible to use everyday suggestions for this. So we cross for void pointer. Void pointer is able to storing pointer to any type as it's far a time-honored pointer kind.

Question forty two. What Are Multidimensional Arrays?

Answer :

Multidimensional arrays make use of a couple of indexes to store records. It is beneficial whilst storing statistics that can not be represented using a single dimensional indexing, consisting of facts representation in a board sport, tables with records saved in multiple column.

Object Oriented Programming in PHP Interview Questions
Question 43. Minimum Number Of Queues Needed To Implement The Priority Queue?

Answer :

Two. One queue is used for actual storing of facts and another for storing priorities.

Question forty four. Are Linked Lists Considered Linear Or Non-linear Data Structure?

Answer :

It virtually relies upon on wherein you plan to use related lists. If you based it on garage, a linked listing is considered non-linear. On the alternative hand, in case you primarily based it on get admission to techniques, then a linked list is taken into consideration linear.

Question forty five. Differentiate Between Push And Pop?

Answer :

Pushing and popping refers to the manner information is stored into and retrieved from a stack.
PUSH – Data being driven/ delivered to the stack.
POP - Data being retrieved from the stack, specifically the topmost statistics.

Question forty six. What Are The Notations Used In Evaluation Of Arithmetic Expressions Using Prefix And Postfix Forms?

Answer :

Polish and Reverse Polish notations.

Question forty seven. How Does Dynamic Memory Allocation Help In Managing Data?

Answer :

Aside from being able to store simple based facts kinds, dynamic memory allocation can integrate one by one allotted dependent blocks to shape composite structures that increase and settlement as needed.

Question 48. When Is A Binary Search Algorithm Best Applied?

Answer :

It is quality implemented to go looking a listing whilst the factors are already so as or taken care of.
The listing right here is searched starting within the center. If that middle cost is not the ideal one, the lower or the top half of is searched in the similar manner.

Question 49. In Rdbms, What Is The Efficient Data Structure Used In The Internal Storage Representation?

Answer :

B+ tree. Because in B+ tree, all the data is stored handiest in leaf nodes, that makes searching less complicated. This corresponds to the data that will be saved in leaf nodes.

Question 50. What Is A Spanning Tree?

Answer :

A spanning tree is a tree related to a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree prepared so that the whole facet weight among nodes is minimized.

Question fifty one. Does The Minimum Spanning Tree Of A Graph Give The Shortest Distance Between Any 2 Specified Nodes?

Answer :

No. The Minimal spanning tree assures that the entire weight of the tree is saved at its minimum. But it would not imply that the gap between any two nodes concerned within the minimal-spanning tree is minimal.

Question fifty two. Which Is The Simplest File Structure? (sequential, Indexed, Random)

Answer :

Sequential is the best record structure.

 

Question 53. Whether Linked List Is Linear Or Non-linear Data Structure?

Answer :

According to Access techniques Linked listing is a linear one. 
According to Storage Linked List is a Non-linear one.

Question 54. In Tree Construction Which Is The Suitable Efficient Data Structure? (array, Linked List, Stack, Queue)

Answer :

Linked list is the right green statistics structure.

Question fifty five. What Is The Type Of The Algorithm Used In Solving The 8 Queens Problem?

Answer :

Backtracking.

Question 56. List Out Few Of The Applications That Make Use Of Multilinked Structures?

Answer :

Sparse matrix.
Index technology.
Question 57. What Are The Types Of Collision Resolution Techniques And The Methods Used In Each Of The Type?

Answer :

Open addressing (closed hashing), The strategies used encompass: Overflow block.
Closed addressing (open hashing), The strategies used include: Linked list, Binary tree.

Question fifty eight. Sorting Is Not Possible By Using Which Of The Following Methods? (insertion, Selection, Exchange, Deletion)

Answer :

Sorting isn't always feasible in Deletion. Using insertion we can carry out insertion kind, the usage of selection we are able to perform choice kind, the usage of alternate we can perform the bubble kind (and different similar sorting techniques). But no sorting method can be executed just the usage of deletion.

Question 59. What Are The Methods Available In Storing Sequential Files?

Answer :

Straight merging.
Natural merging.
Polyphase sort.
Distribution of Initial runs.
Question 60. List Out Few Of The Application Of Tree Data-shape?

Answer :

The manipulation of Arithmetic expression.
Symbol Table construction.
Syntax evaluation.




CFG