- World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.

Get it now !!
Send your Resume to 6000 Companies
Structures in C Interview Questions & Answers - Learning Mode

Structures in C Interview Questions & Answers - Learning Mode

A struct in the C programming language (and many derivatives) is a complex data type declaration that defines a physically grouped list of variables to be placed under one name in a block of memory, allowing the different variables to be accessed via a single pointer, or the struct declared name which returns the same. When programming, it is often convenient to have a single name with which to refer to a group of a related values. Structures provide a way of storing many different values in variables of potentially different types under the same name.

Try Structures in C Interview Questions & Answers - Exam Mode

1 2 Next

Sort By : Latest First | Oldest First | By Rating

Structures in C Interview Questions & Answers - Learning Mode
Try Structures in C Interview Questions & Answers - Exam Mode
Question: What is the quickest sorting method to use?

Answer: The answer depends on what you mean by quickest. For most sorting problems, it just doesn?t matter how quick the sort is because it is done infrequently or other operations take significantly more time anyway. Even in cases in which sorting speed is of the essence, there is no one answer. It depends on not only the size and nature of the data, but also the likely order. No algorithm is best in all cases.

There are three sorting methods in this author?s ?toolbox? that are all very fast and Source:
Question: What is the easiest sorting method to use?

Answer: The answer is the standard library function qsort(). It?s the easiest sort by far for several reasons:

It is already written.
It is already debugged.
It has been optimized as much as possible (usually).
Void qsort(void *buf, size_t num, size_t size, int (*comp)(const void *ele1, const void *ele2));

Question: What is hashing?

Answer: To hash means to grind up, and that?s essentially what hashing is all about. The heart of a hashing algorithm is a hash function that takes your nice, neat data and grinds it into some random-looking integer.

The idea behind hashing is that some data either has no inherent ordering (such as images) or is expensive to compare (such as images). If the data has no inherent ordering, you can?t perform comparison searches.

If the data is expensive to compare, the number of comparisons u Source:
Question: How can we check whether the contents of two structure variables are same or not?

Question: What is the quickest searching method to use?

Answer: A binary search, such as bsearch() performs, is much faster than a linear search. A hashing algorithm can provide even faster searching. One particularly interesting and fast method for searching is to keep the data in a ?digital trie.? A digital trie offers the prospect of being able to search for an item in essentially a constant amount of time, independent of how many items are in the data set.

A digital trie combines aspects of binary searching, radix searching, and hashing. The term Source:
Question: Data structure:
Syntax of single inheritance with example program and explanation

Answer: for Example of single inheritance is father and son relation
class CFather
void Gender () {cout<<"Male" ;}
void Blood () {cout<<"Red";}
void Initial (){cout<<"Angajala";}
void Address (){cout <<"******" ;}


Class CDerived:public CBase
}; Source:
Question: What is the easiest searching method to use?

Answer: Just as qsort() was the easiest sorting method, because it is part of the standard library, bsearch() is the
easiest searching method to use. If the given array is in the sorted order bsearch() is the best method.

Following is the prototype for bsearch():

void *bsearch(const void *key, const void *buf, size_t num, size_t size, int (*comp)(const void *, const void*));

Another simple searching method is a linear search. A linear search is not as fast as bsearch() for search Source:
Question: How can I sort things that are too large to bring into memory?

Answer: A sorting program that sorts items that are on secondary storage (disk or tape) rather than primary storage (memory) is called an external sort. Exactly how to sort large data depends on what is meant by ?too large to fit in memory.? If the items to be sorted are themselves too large to fit in memory (such as images), but there aren?t many items, you can keep in memory only the sort key and a value indicating the data?s location on disk. After the key/value pairs are sorted, the data is rearrang Source:
Question: How can you calculate number of nodes in a circular Linked List?

Answer: struct node

{ int data;

struct node *next;


i write just function here

int count(struct node *pp)

{ struct node *start;

int count=0;



{ start=start->next;

count++; }

return count;


Question: Whats is structure padding?Say a given structure
int a;
char c;
float d;
the size of structure is 7 here.
But structure padding is done what will be the size of the struct?Will it change and how?How to avoid this?is it necessary?

Answer: Integers and floats :compilers will try to place these variables at addresses which are in multiples of 2 or 4(in 16-bit system) now in this case 1 byte can be padded...we can store integers and floats at start to avoid padding Source:
Question: Can we use functions within a structure?

Answer: No,You cannot use functions within structure,it is compilation error but in c++ you can do it. Source:
Question: How do you sort names using circular linked list in c like sorting names after every insertion?

Answer: Have a Circular linked list, initially empty. Keep track of the start of the list node, initially empty. Call this start as head node. Then take the first item to be inserted. Insert in the list. Take the next item. Move thru the list till you find an element >= the item to be inserted. Insert the item before the element in the circular list. Update head node if required. Take the next item, traverse through the list similarly till you find an element >= the item to be inserted. Insert Source:
Question: How can I search for data in a linked list?

Answer: Unfortunately, the only way to search a linked list is with a linear search, because the only way a linked list?s members can be accessed is sequentially. Sometimes it is quicker to take the data from a linked list and store it in a different data structure so that searches can be more efficient. Source:
Question: What use of structure and union?

Answer: structure is a user defined data type,that is collection of hetrogeneous data types. if we have to assign memory to a record.for eg,book record,we can declare it as
struct book
char name[20];
int pages;
fload price;
struct book s1,s2;

in last line we have declared two variable of struct type,now the basic data types variables will be recognized in the form of structure. and the memory allocated to above structure will be char(1*20)+int(2)+ float(4)= 26 Source:
Question: What is the difference between Structure and Union?

Answer: The Main diff is Structure is Allocate the memory in asper the Data type.But Union is Allocate the Memory in max size of Declare the vari to all. Source:
Question: What is the difference between structure and union?

Answer: there are differences ,but i know a single point that is
struct sat
int i;
char j;
the output is 3; but in case of union...
union sat
int i;char j;}bat;
the output is 2;
the reason is the union considers the datatype of high value,but structure considers all values equally. Source:
Question: How do you use a structure?

Answer: A structure is a value type data type. When you want a single variable to hold related data of various data types, you can create a structure. To create a structure you use the struct keyword. Source:
Question: How to perform matrix multiplication using Double linked lists?


Question: program to print diamond shape

Answer: No answer available currently.
Question: struct Foo
char *pName;
struct Foo *obj = malloc(sizeof(struct Foo));
strcpy(obj->pName,"Your Name");
printf("%s", obj->pName);


It prints Your Name on my compiler....I dont see any reasons why it shouldn't....even a char pointer prints until it finds the end of line....


1 2 Next

India News Network
Latest 20 Questions
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
"Holiday Packages" announced as an advertisement are an example of _________: (a) Offer (b) Counter Offer (c) Invitation to Offer (d) None of the above
A match fixing contract between a player and a broker is a: (a) Valid Contract (b) Unenforceable Contract (c) Void Contract (d) Illegal Contract
When a bookseller sells a book on cash payment then it is called as ___________: (a) Unilateral Contract (b) Bilateral Contract (c) Executed Contract (d) Executory Contract
____________ agreements are created by situation: (a) Written (b) Oral (c) Void (d) Implied
Cache = 0.6875 Seconds