InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How is search done in #include and #include “somelibrary.h” according to C standard?(a) When former is used, current directory is searched and when latter is used, standard directory is searched(b) When former is used, standard directory is searched and when latter is used, current directory is searched(c) When former is used, search is done in implementation defined manner and when latter is used, current directory is searched(d) For both, search for ‘somelibrary’ is done in implementation-defined placesI have been asked this question during an interview.Enquiry is from File Inclusion topic in chapter C Functions and Structure of a Program of C |
|
Answer» RIGHT option is (d) For both, SEARCH for ‘SOMELIBRARY’ is DONE in implementation-defined places Easiest explanation - None. |
|
| 2. |
#pragma exit is primarily used for?(a) Checking memory leaks after exiting the program(b) Informing Operating System that program has terminated(c) Running a function at exiting the program(d) No such preprocessor existThis question was posed to me in my homework.I want to ask this question from C-Preprocessor in chapter C Functions and Structure of a Program of C |
|
Answer» Right option is (C) Running a function at EXITING the program |
|
| 3. |
Automatic variables are allocated memory in ___________(a) heap(b) Data segment(c) Code segment(d) stackI have been asked this question by my college professor while I was bunking the class.The origin of the question is Automatic Variables in chapter C Functions and Structure of a Program of C |
| Answer» | |
| 4. |
Which directory the compiler first looks for the file when using #include?(a) Current directory where program is saved(b) C:COMPILERINCLUDE(c) S:SOURCEHEADERS(d) Both C:COMPILERINCLUDE and S:SOURCEHEADERS simultaneouslyThe question was asked in an interview for job.This is a very interesting question from File Inclusion in portion C Functions and Structure of a Program of C |
|
Answer» Right CHOICE is (b) C:COMPILERINCLUDE |
|
| 5. |
#include are _______ files and #include “somefile.h” ________ files.(a) Library, Library(b) Library, user-created header(c) User-created header, library(d) They can include all types of fileI had been asked this question in semester exam.I'm obligated to ask this question of C-Preprocessor in chapter C Functions and Structure of a Program of C |
|
Answer» The correct ANSWER is (d) They can include all types of FILE |
|
| 6. |
Which of the following is a storage specifier?(a) enum(b) union(c) auto(d) volatileI had been asked this question during a job interview.My enquiry is from Automatic Variables in section C Functions and Structure of a Program of C |
|
Answer» Right choice is (C) auto |
|
| 7. |
What is the scope of an external variable?(a) Whole source file in which it is defined(b) From the point of declaration to the end of the file in which it is defined(c) Any source file in a program(d) From the point of declaration to the end of the file being compiledThis question was addressed to me by my school teacher while I was bunking the class.Enquiry is from Scope of a Variable topic in section C Functions and Structure of a Program of C |
|
Answer» The CORRECT OPTION is (d) From the point of DECLARATION to the END of the file being compiled |
|
| 8. |
Conditional inclusion can be used for ___________(a) Preventing multiple declarations of a variable(b) Check for existence of a variable and doing something if it exists(c) Preventing multiple declarations of same function(d) All of the mentionedThe question was posed to me in an interview for internship.This interesting question is from Conditional Inclusion in chapter C Functions and Structure of a Program of C |
|
Answer» CORRECT OPTION is (d) All of the mentioned Best EXPLANATION: NONE. |
|
| 9. |
The C-preprocessors are specified with _________symbol.(a) #(b) $(c) ” ”(d) &The question was asked in examination.I'd like to ask this question from C-Preprocessor in section C Functions and Structure of a Program of C |
|
Answer» Right CHOICE is (a) # |
|
| 10. |
#include statement must be written __________(a) Before main()(b) Before any scanf/printf(c) After main()(d) It can be written anywhereThis question was posed to me during an online interview.Question is from C-Preprocessor topic in portion C Functions and Structure of a Program of C |
|
Answer» Right answer is (b) Before any scanf/printf |
|
| 11. |
Automatic variables are stored in ________(a) stack(b) data segment(c) register(d) heapThis question was addressed to me by my school teacher while I was bunking the class.Enquiry is from Automatic Variables in portion C Functions and Structure of a Program of C |
|
Answer» CORRECT CHOICE is (a) stack For EXPLANATION: NONE. |
|
| 12. |
What would happen if you create a file stdio.h and use #include “stdio.h”?(a) The predefined library file will be selected(b) The user-defined library file will be selected(c) Both the files will be included(d) The compiler won’t accept the programThis question was posed to me during an internship interview.My doubt is from File Inclusion in portion C Functions and Structure of a Program of C |
|
Answer» The CORRECT ANSWER is (B) The user-defined library file will be selected |
|
| 13. |
Which of following is not accepted in C?(a) static a = 10; //static as(b) static int func (int); //parameter as static(c) static static int a; //a static variable prefixed with static(d) all of the mentionedThe question was asked by my school teacher while I was bunking the class.My question is based upon Static Variables in division C Functions and Structure of a Program of C |
|
Answer» CORRECT choice is (c) STATIC static int a; //a static variable prefixed with static Best EXPLANATION: NONE. |
|
| 14. |
If the file name is enclosed in angle brackets, then ___________(a) The preprocessor treats it as a user-defined file(b) The preprocessor treats it as a system-defined file(c) The preprocessor treats it as a user-defined file & system-defined file(d) None of the mentionedThe question was posed to me during an online exam.This question is from File Inclusion topic in division C Functions and Structure of a Program of C |
|
Answer» The CORRECT ANSWER is (b) The PREPROCESSOR TREATS it as a system-defined file |
|
| 15. |
Preprocessor feature that supply line numbers and filenames to compiler is called?(a) Selective inclusion(b) macro substitution(c) Concatenation(d) Line controlThis question was posed to me in homework.My enquiry is from C-Preprocessor in section C Functions and Structure of a Program of C |
|
Answer» The CORRECT option is (d) Line control |
|
| 16. |
Automatic variables are initialized to ___________(a) Zero(b) Junk value(c) Nothing(d) Both Zero & Junk valueThe question was posed to me by my college director while I was bunking the class.Question is taken from Automatic Variables in chapter C Functions and Structure of a Program of C |
|
Answer» The correct option is (B) JUNK value |
|
| 17. |
Which among the following is the correct syntax to declare a static variable register?(a) static register a;(b) register static a;(c) Both static register a; and register static a;(d) We cannot use static and register togetherI got this question by my college director while I was bunking the class.This interesting question is from Register Variables topic in chapter C Functions and Structure of a Program of C |
|
Answer» The CORRECT choice is (d) We cannot use STATIC and register together |
|
| 18. |
What is the scope of an automatic variable?(a) Exist only within that scope in which it is declared(b) Cease to exist after the block is exited(c) Exist only within that scope in which it is declared & exist after the block is exited(d) All of the mentionedThe question was asked in unit test.My question is from Automatic Variables in portion C Functions and Structure of a Program of C |
|
Answer» Right OPTION is (C) Exist only within that scope in which it is declared & exist after the block is exited |
|
| 19. |
When compiler accepts the request to use the variable as a register?(a) It is stored in CPU(b) It is stored in cache memory(c) It is stored in main memory(d) It is stored in secondary memoryI have been asked this question in unit test.I would like to ask this question from Register Variables topic in portion C Functions and Structure of a Program of C |
|
Answer» CORRECT OPTION is (a) It is STORED in CPU The EXPLANATION: NONE. |
|
| 20. |
Register storage class can be specified to global variables.(a) True(b) False(c) Depends on the compiler(d) Depends on the standardI have been asked this question during an internship interview.My query is from Register Variables in chapter C Functions and Structure of a Program of C |
| Answer» | |
| 21. |
Is initialisation mandatory for local static variables?(a) Yes(b) No(c) Depends on the compiler(d) Depends on the standardI have been asked this question during an online exam.This intriguing question comes from Static Variables topic in portion C Functions and Structure of a Program of C |
|
Answer» The CORRECT CHOICE is (B) No |
|
| 22. |
Functions can return structure in C?(a) True(b) False(c) Depends on the compiler(d) Depends on the standardI had been asked this question during a job interview.My question is from Functions Returning Non-integers topic in portion C Functions and Structure of a Program of C |
|
Answer» CORRECT OPTION is (a) True Explanation: NONE. |
|
| 23. |
If storage class is not specified for a local variable, then the default class will be auto.(a) True(b) False(c) Depends on the standard(d) None of the mentionedI have been asked this question during an online interview.Enquiry is from Automatic Variables topic in division C Functions and Structure of a Program of C |
|
Answer» RIGHT OPTION is (a) True Easiest EXPLANATION - NONE. |
|
| 24. |
What is #include directive?(a) Tells the preprocessor to grab the text of a file and place it directly into the current file(b) Statements are not typically placed at the top of a program(c) All of the mentioned(d) None of the mentionedThis question was posed to me in class test.This intriguing question comes from C-Preprocessor topic in section C Functions and Structure of a Program of C |
|
Answer» Correct answer is (a) TELLS the preprocessor to grab the text of a file and PLACE it directly into the CURRENT file |
|
| 25. |
register keyword mandates compiler to place it in machine register.(a) True(b) False(c) Depends on the standard(d) None of the mentionedI have been asked this question in a job interview.The question is from Register Variables in division C Functions and Structure of a Program of C |
|
Answer» CORRECT ANSWER is (B) False Easy EXPLANATION - NONE. |
|
| 26. |
Assignment statements assigning value to local static variables are executed only once.(a) True(b) False(c) Depends on the code(d) None of the mentionedThe question was asked by my school principal while I was bunking the class.This intriguing question comes from Static Variables in division C Functions and Structure of a Program of C |
|
Answer» The CORRECT CHOICE is (B) False |
|
| 27. |
Can we use a function as a parameter of another function? [Eg: void wow(int func())].(a) Yes, and we can use the function value conveniently(b) Yes, but we call the function again to get the value, not as convenient as in using variable(c) No, C does not support it(d) This case is compiler dependentI had been asked this question by my school teacher while I was bunking the class.I want to ask this question from Basics of Functions topic in chapter C Functions and Structure of a Program of C |
|
Answer» The CORRECT ANSWER is (C) No, C does not SUPPORT it |
|
| 28. |
Which of the following file extensions are accepted with #include?(a) .h(b) .in(c) .com(d) All of the mentionedThis question was posed to me in final exam.This interesting question is from File Inclusion in portion C Functions and Structure of a Program of C |
|
Answer» The correct answer is (d) All of the mentioned |
|
| 29. |
Which of the following are C preprocessors?(a) #ifdef(b) #define(c) #endif(d) all of the mentionedThe question was posed to me in an international level competition.This is a very interesting question from C-Preprocessor topic in section C Functions and Structure of a Program of C |
|
Answer» RIGHT CHOICE is (d) all of the mentioned Explanation: NONE. |
|
| 30. |
What is #include ?(a) Preprocessor directive(b) Inclusion directive(c) File inclusion directive(d) None of the mentionedThis question was posed to me during an online exam.This key question is from C-Preprocessor topic in chapter C Functions and Structure of a Program of C |
|
Answer» The CORRECT ANSWER is (a) PREPROCESSOR directive |
|
| 31. |
What is the default return type if it is not specified in function definition?(a) void(b) int(c) double(d) short intThe question was asked in an international level competition.This key question is from Functions Returning Non-integers topic in division C Functions and Structure of a Program of C |
| Answer» | |
| 32. |
If the file name is enclosed in double quotation marks, then _________(a) The preprocessor treats it as a user-defined file(b) The preprocessor treats it as a system-defined file(c) The preprocessor treats it as a user-defined file & system-defined file(d) None of the mentionedI have been asked this question in an international level competition.The above asked question is from File Inclusion in division C Functions and Structure of a Program of C |
|
Answer» RIGHT OPTION is (a) The PREPROCESSOR TREATS it as a user-defined file Explanation: NONE. |
|
| 33. |
C preprocessors can have compiler specific features.(a) True(b) False(c) Depends on the standard(d) Depends on the platformThe question was posed to me during an interview for a job.Query is from C-Preprocessor in section C Functions and Structure of a Program of C |
|
Answer» Correct OPTION is (a) True |
|
| 34. |
Property which allows to produce different executable for different platforms in C is called?(a) File inclusion(b) Selective inclusion(c) Conditional compilation(d) Recursive macrosI had been asked this question by my school principal while I was bunking the class.I would like to ask this question from C-Preprocessor in section C Functions and Structure of a Program of C |
|
Answer» RIGHT choice is (C) CONDITIONAL compilation To explain I would SAY: Conditional compilation is the preprocessor FACILITY to produce a different executable. |
|
| 35. |
Functions have static qualifier for its declaration by default.(a) True(b) False(c) Depends on the compiler(d) Depends on the standardI got this question by my college director while I was bunking the class.I would like to ask this question from Static Variables topic in division C Functions and Structure of a Program of C |
| Answer» | |
| 36. |
The preprocessor provides the ability for _______________(a) The inclusion of header files(b) The inclusion of macro expansions(c) Conditional compilation and line control(d) All of the mentionedThis question was addressed to me by my college professor while I was bunking the class.The above asked question is from C-Preprocessor topic in division C Functions and Structure of a Program of C |
|
Answer» The correct option is (d) All of the mentioned |
|
| 37. |
C preprocessor is conceptually the first step during compilation.(a) True(b) False(c) Depends on the compiler(d) Depends on the standardI got this question in semester exam.This key question is from C-Preprocessor in section C Functions and Structure of a Program of C |
|
Answer» RIGHT ANSWER is (a) True The EXPLANATION: NONE. |
|
| 38. |
Functions in C are always _________(a) Internal(b) External(c) Both Internal and External(d) External and Internal are not valid terms for functionsThis question was addressed to me during an interview.Asked question is from External Variables topic in section C Functions and Structure of a Program of C |
|
Answer» Correct choice is (B) External |
|
| 39. |
How is search done in #include and #include”somelibrary.h” normally or conventionally?(a) When former is used, current directory is searched and when latter is used, standard directory is searched(b) When former is used, predefined directory is searched and when latter is used, current directory is searched and then predefined directories are searched(c) When former is used, search is done in implementation defined manner and latter is used to search current directory(d) For both, search for somelibrary is done in implementation-defined mannerThe question was asked in an internship interview.The query is from File Inclusion in chapter C Functions and Structure of a Program of C |
|
Answer» The CORRECT option is (b) When former is USED, predefined directory is searched and when latter is used, current directory is searched and then predefined DIRECTORIES are searched |
|
| 40. |
What is the sequence for preprocessor to look for the file within ?(a) The predefined location then the current directory(b) The current directory then the predefined location(c) The predefined location only(d) The current directory locationI had been asked this question during an interview for a job.I need to ask this question from File Inclusion in chapter C Functions and Structure of a Program of C |
|
Answer» CORRECT answer is (a) The PREDEFINED location then the current directory To EXPLAIN I would say: <> first SEARCHES the predefined location for the specified file and then the current directory. |
|
| 41. |
Which of the following storage class supports char data type?(a) register(b) static(c) auto(d) all of the mentionedThis question was addressed to me in final exam.The doubt is from Automatic Variables topic in section C Functions and Structure of a Program of C |
|
Answer» RIGHT OPTION is (d) all of the mentioned Best EXPLANATION: NONE. |
|
| 42. |
What is the scope of an automatic variable?(a) Within the block it appears(b) Within the blocks of the block it appears(c) Until the end of program(d) Within the block it appears & Within the blocks of the block it appearsI had been asked this question in an online interview.This question is from Automatic Variables in chapter C Functions and Structure of a Program of C |
|
Answer» The CORRECT OPTION is (d) Within the block it appears & Within the BLOCKS of the block it appears |
|
| 43. |
For each #if, #ifdef, and #ifndef directive.(a) There are zero or more #elif directives(b) Zero or one #else directive(c) One matching #endif directive(d) All of the mentionedThe question was asked in a national level competition.I need to ask this question from Conditional Inclusion topic in portion C Functions and Structure of a Program of C |
|
Answer» RIGHT OPTION is (d) All of the mentioned The BEST EXPLANATION: NONE. |
|
| 44. |
Which of the following operation is not possible in a register variable?(a) Reading the value into a register variable(b) Copy the value from a memory variable(c) Global declaration of register variable(d) All of the mentionedThe question was asked in exam.My enquiry is from Register Variables in division C Functions and Structure of a Program of C |
|
Answer» CORRECT ANSWER is (d) All of the mentioned The BEST I can EXPLAIN: NONE. |
|
| 45. |
Which data type can be stored in register?(a) int(b) long(c) float(d) all of the mentionedI have been asked this question in an online interview.This interesting question is from Register Variables in section C Functions and Structure of a Program of C |
|
Answer» CORRECT OPTION is (d) all of the mentioned To EXPLAIN I would say: NONE. |
|
| 46. |
What is the format identifier for “static a = 20.5;”?(a) %s(b) %d(c) %f(d) Illegal declaration due to absence of data typeThis question was posed to me in my homework.My question is from Static Variables topic in section C Functions and Structure of a Program of C |
|
Answer» Right OPTION is (B) %d |
|
| 47. |
Automatic variables are_________(a) Declared within the scope of a block, usually a function(b) Declared outside all functions(c) Declared with the auto keyword(d) Declared within the keyword externI got this question during an interview for a job.My question comes from Automatic Variables in division C Functions and Structure of a Program of C |
|
Answer» Right ANSWER is (a) Declared WITHIN the scope of a BLOCK, usually a function |
|
| 48. |
Automatic variables are allocated space in the form of a __________(a) stack(b) queue(c) priority queue(d) randomI had been asked this question in unit test.My query is from Automatic Variables in section C Functions and Structure of a Program of C |
|
Answer» CORRECT ANSWER is (a) stack The BEST EXPLANATION: NONE. |
|