C Programming Questions and Answers – Table Lookup – 2

«
»
This section on tricky C questions focuses on “Table Lookup”. One shall practice these tricky questions to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C Programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our C questions come with detailed explanation of the answers which helps in better understanding of C concepts.

Here is a listing of C programming questions on “Table Lookup” along with answers, explanations and/or solutions:

1. Which function is responsible for searching in the table? (For #define IN 1, the name IN and replacement text 1 are stored in a “table”)
a) findout(s);
b) lookup(s);
c) find(s);
d) lookfor(s);
View Answer

Answer: b
Explanation: None.
advertisement

2. Which algorithm is used for searching in the table?
a) List search
b) Informed search
c) Hash search
d) Adversarial search
View Answer

Answer: c
Explanation: None.

3. Which function is responsible for recording the name “s” and the replacement text “t” in a table?
a) install(s, t);
b) fix(s, t);
c) setup(s, t);
d) settle(s, t);
View Answer

Answer: a
Explanation: None.
advertisement
advertisement

4. Which of the following statement is true?
a) Install function uses lookup
b) lookup function uses install
c) Install and lookup function work independently
d) None of the mentioned
View Answer

Answer: a
Explanation: None.

5. What happens when install(s, t) finds that the name being installed is already present in the table?
a) It doesn’t modify the name in the table
b) It modifies the name with new definition
c) It modifies off the new definition has higher priority
d) It creates a new table and add the new definition in it
View Answer

Answer: b
Explanation: None.
advertisement

6. In what situation, install function returns NULL?
a) When there is no memory for adding new name
b) When the name to be defined is already present in the table
c) Whenever a new name is added to the table
d) All of the mentioned
View Answer

Answer: a
Explanation: None.

7. What will be the output of the following C code?

advertisement
  1.     #include <stdio.h>
  2.     struct student
  3.     {
  4.         char a[];
  5.     };
  6.     void main()
  7.     {
  8.         struct student s;
  9.         printf("%d", sizeof(struct student));
  10.     }

a) Compile time error
b) 8
c) 1
d) Varies
View Answer

Answer: a
Explanation: None.
advertisement

8. What will be the output of the following C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         struct p
  5.         {
  6.             char *name;
  7.             struct p *next;
  8.         };
  9.         struct p *ptrary[10];
  10.         struct p p, q;
  11.         p.name = "xyz";
  12.         p.next = NULL;
  13.         ptrary[0] = &p;
  14.         q.name = (char*)malloc(sizeof(char)*3);
  15.         strcpy(q.name, p.name);
  16.         q.next = &q;
  17.         ptrary[1] = &q;
  18.         printf("%s\n", ptrary[1]->next->next->name);
  19.     }

a) Compile time error
b) Depends on the compiler
c) Undefined behaviour
d) xyz
View Answer

Answer: d
Explanation: None.

Sanfoundry Global Education & Learning Series – C Programming Language.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement

Leave a Comment

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter