C Programming Questions and Answers – Table Lookup – 2

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Table Lookup – 2”.

Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.

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.

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.
advertisement

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.

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.
Free 30-Day Python Certification Bootcamp is Live. Join Now!

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.

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?

  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.

To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). 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!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 40s–60s and exploring new directions in your career, I also offer mentoring. Learn more here.