Explore topic-wise InterviewSolutions in .

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.

void (*signal(int sig, void (*func)(int)))(int);If the value of func is SIG_IGN then _________(a) the signal will be ignored(b) default handling for that signal will occur(c) The signal() function will fail to execute(d) the signal will be ignoredI have been asked this question by my college professor while I was bunking the class.My enquiry is from Signal Handling topic in section C Library of C

Answer»

The correct answer is (a) the signal will be ignored

Easy EXPLANATION - SIG_IGN is one of the WAYS in signal() function in which receipt of the signal NUMBER SIG is subsequently handled. The signal will be ignored if the value of FUNC is SIG_IGN.

2.

The macro definition of INT_MIN is ____________(a) –INT_MAX – 1(b) INT_MAX – 1(c) –INT_MAX + 1(d) INT_MAX + 1The question was posed to me by my college director while I was bunking the class.Question is from Implementation-Defined Limits in section C Library of C

Answer»

The CORRECT ANSWER is (a) –INT_MAX – 1

Explanation: The MACRO DEFINITION of INT_MIN is –INT_MAX – 1.

3.

What does raise functions declared in signal.h do?(a) reports a synchronous signal(b) let’s you specify handling of signals(c) reports a asynchronous signal(d) doesn’t let you specify handling of signalsThe question was asked by my school principal while I was bunking the class.My question is from Signal Handling in portion C Library of C

Answer»

Correct ANSWER is (a) reports a SYNCHRONOUS signal

The best explanation: The FUNCTION raise DEFINED under the header file signal. H reports a synchronous signal.

4.

The void longjmp( jmp-buf env, int val) function causes setjmp() macro to return _______ value; if val is 0.(a) zero(b) one(c) null(d) no returnI have been asked this question in an online interview.My doubt is from Non-Local Jumps in division C Library of C

Answer»

The correct choice is (b) one

The EXPLANATION is: The longjmp() function cannot CAUSE the setjmp() to return value zero,if the VARIABLE VAL is zero. It always return one when the value of val is 0.

5.

Which header file is used to define data formats and currency symbols?(a) setjmp.h(b) locale.h(c) stdarg.h(d) assert.hI got this question during an online exam.This interesting question is from Localization topic in section C Library of C

Answer»

Correct answer is (b) LOCALE.H

The explanation: locale. h is the header file which defines the LOCATION SPECIFIC settings, such as data formats and currency location.

6.

The value of tm_isdst is ____ when DST( Daylight Savings Time) is in effect, ______ when DST is not in effect and ______ when the DST status is unknown.(a) -1, 1, 0(b) 1, 0, -1(c) 0, 1, -1(d) 1, -1, 0The question was asked during an interview.The question is from Date and Time Function topic in division C Library of C

Answer»

Correct answer is (B) 1, 0, -1

Best explanation: The VALUE of tm_isdst is 1 when DAYLIGHT Savings Time is in EFFECT, 0 when DSP is not in the effect and -1 when DST status is not known.

7.

The purpose of the function ctime() is that ___________(a) it returns a string representing the local time(b) it returns a void string(c) it returns a string representing the time in UTC format(d) it returns a string representing the time stored in a structureI got this question in class test.I'm obligated to ask this question of Date and Time Functions in chapter C Library of C

Answer»

Correct OPTION is (a) it returns a STRING representing the local time

To explain: The library function ctime() returns a string representation of the local time. The function asctime() returns a string representing the time stored in a STRUCTURE.

8.

How many times does the function longjmp() returns?(a) once(b) twice(c) thrice(d) neverThis question was posed to me in an interview.I would like to ask this question from Non-Local Jumps topic in section C Library of C

Answer»

Correct choice is (d) never

For EXPLANATION: longjmp() FUNCTION defined under setjmp.h header FILE does not return any VALUE.

9.

The header file setjmp.h is used to __________(a) set location specific information(b) control low-level calls and returns to and from functions(c) handle signals reported during a program’s execution(d) manipulate strings (character arrays)I had been asked this question in a job interview.I would like to ask this question from Non-Local Jumps topic in division C Library of C

Answer»

The CORRECT option is (b) control low-level CALLS and returns to and from FUNCTIONS

Explanation: The header file setjmp.h is used to control low-level calls and returns to and from functions.

10.

longjmp() function is the only function defined under the header file setjmp.h?(a) true(b) falseI have been asked this question by my school teacher while I was bunking the class.This intriguing question originated from Non-Local Jumps in portion C Library of C

Answer»

Correct option is (a) true

The BEST I can EXPLAIN: The only FUNCTION DEFINED under the header file setjmp.h is longjmp().LONGJMP() resets the registers to the values SAVED in an environment.

11.

If setjmp() macro returns directly from the macro invocation, it______(a) returns zero(b) returns non-zero(c) produces error(d) nothing can be saidThe question was asked by my school teacher while I was bunking the class.I want to ask this question from Non-Local Jumps topic in section C Library of C

Answer»

Correct answer is (a) returns ZERO

The best EXPLANATION: The setjmp() MACRO returns zero if the return is from a direct invocation.

12.

The maximum value of a signed char is not the same as the maximum value of an unsigned char.(a) True(b) FalseThis question was posed to me during an internship interview.My enquiry is from Implementation-Defined Limits in chapter C Library of C

Answer»

The correct option is (a) True

To EXPLAIN I WOULD say: The maximum value of a signed char is 127 and that the maximum value of an unsigned char is 255. THUS it is clear that the maximum value of a signed char is not the same as the maximum value of an unsigned char.

13.

Some types and macros defined under the header file stddef.h may be defined under other header files too.(a) True(b) FalseThe question was posed to me during a job interview.The origin of the question is Standard Definition in division C Library of C

Answer» RIGHT answer is (a) True

The best EXPLANATION: There are some types and MACROS which are defined under VARIOUS other header files, in addition to being defined under stddef.h. For example, the type size_t is defined under stdio.h, stdlib.h, string.h ETC in addition to being defined under stddef.h.
14.

A non-zero value is returned, if setjmp() returns from a longjmp() function call.(a) false(b) trueI had been asked this question in an interview.I'm obligated to ask this question of Non-Local Jumps in section C Library of C

Answer» CORRECT option is (b) true

Easiest EXPLANATION - The setjmp() macro returns a nonzero value, if the RETURN is from a call to the longjmp() FUNCTION.
15.

Select the function that reads or sets location dependent information.(a) longjmp()(b) setlocale()(c) assert()(d) toupper()This question was addressed to me in an interview for internship.This key question is from Localization in division C Library of C

Answer»

The CORRECT OPTION is (b) setlocale()

EASY explanation - setlocale()function reads or SETS location dependent information.

The function declaration is as follows:

char *setlocale(int category, const char loc).

16.

Which of the following functions is used to convert the date and time into a calendar format?(a) difftime()(b) clock()(c) mktime()(d) ctime()This question was addressed to me in an interview.My question comes from Date and Time Function topic in portion C Library of C

Answer»

Right option is (c) mktime()

The best I can EXPLAIN: The function mktime() is used to convert the DATE and time into a calendar FORMAT. The function difftime() is used to find the difference between two specified timings, the function CLOCK() is used to return the number of ticks.

17.

Which of the following library functions is used to read location dependent information?(a) localtime()(b) localeconv()(c) localcon()(d) local()This question was addressed to me in a job interview.This is a very interesting question from Date and Time Function topic in chapter C Library of C

Answer»

Right OPTION is (b) localeconv()

The explanation is: localeconv() is used to read the LOCATION dependent information. The function used to FIND the current TIME is localtime().

18.

Which among the given header file is used to handle different signals reported during program execution?(a) stdarg.h(b) assert.h(c) signal.h(d) setjmp.hThis question was posed to me in exam.This interesting question is from Signal Handling topic in chapter C Library of C

Answer» RIGHT choice is (c) signal.h

To explain I would say: signal.h is the header file that defines one TYPE and two FUNCTIONS and MANY MACROS to handle different signals reported during the execution of the program.
19.

Which of the following library functions returns the time in UTC (Greenwich mean time) format?(a) localtime()(b) gettime()(c) gmtime()(d) settime()I have been asked this question during an online interview.My question comes from Date and Time Functions topic in division C Library of C

Answer»

Right option is (c) gmtime()

EXPLANATION: The library FUNCTION gmtime() returns the time in UTC format. To FIND the current time, we USE the function LOCALTIME().

20.

Select the macro that affects the information provided by localeconv function.(a) LC_ALL(b) LC_COLLATE(c) LC_NUMERIC(d) LC_CTYPEThe question was posed to me in a national level competition.This interesting question is from Localization in chapter C Library of C

Answer»

Right choice is (C) LC_NUMERIC

The EXPLANATION: LC_NUMERIC is the macro defined under the HEADER FILE locale.h which affects decimal point formatting and INFORMATIONS provided by localeconv function.

21.

Which macro sets everything defined under locale. h?(a) LC_ALL(b) LC_COLLATE(c) LC_SET(d) LC_TIMEThe question was posed to me by my college director while I was bunking the class.Question is taken from Localization topic in portion C Library of C

Answer»

The CORRECT CHOICE is (a) LC_ALL

The BEST explanation: LC_ALL is the MACRO which sets everything. It is defined under header file locale.h.

22.

Which macro is used in the setlocale() function?(a) LC_SET(b) FLT_RADIX 2(c) LC_MESSAGES(d) SHRT_MAXThe question was asked by my college director while I was bunking the class.The above asked question is from Localization topic in division C Library of C

Answer»

The correct option is (C) LC_MESSAGES

The EXPLANATION: LC_MESSAGES in the function char *setlocale(char category, const char loc) is used for system RESPONSES.

23.

Select the correct statement.(a) LC_MONETARY affects the monetary information(b) LC_MONETARY does not affect the monetary information(c) LC_ALL does not set everything(d) LC_CTYPE affects only one character functionsI got this question in a national level competition.The above asked question is from Localization topic in section C Library of C

Answer»

Right ANSWER is (a) LC_MONETARY affects the MONETARY INFORMATION

The EXPLANATION: LC_MONETARY is the macro defined under header file locale.h which affects the monetary information provided by localeconv function.

24.

A less common use of setjmp.h is to create syntax similar to ____________(a) errno(b) variable arguments(c) coroutines(d) retvalThis question was posed to me in homework.I would like to ask this question from Non-Local Jumps topic in division C Library of C

Answer» RIGHT CHOICE is (c) coroutines

To EXPLAIN: setjmp.h is sometime is used to create syntax similar to coroutines. Coroutines are COMPUTER PROGRAM components.
25.

The macros defined under the header file limits.h are not defined under any other header file.(a) False(b) TrueI have been asked this question in an interview for internship.I'd like to ask this question from Implementation-Defined Limits in portion C Library of C

Answer» CORRECT choice is (b) True

Explanation: Macros such as INT_MAX, ULONG_MAX ETC which are defined under the header file limits.h are not defined under any other header file.
26.

A type whose alignment requirement is at least as large as that of every data type ____________(a) max_align_t(b) ptrdiff_t(c) size_t(d) nullThe question was posed to me during an online exam.My question comes from Standard Definition in chapter C Library of C

Answer»

Correct option is (d) null

Explanation: The alignment of the type max_align_t is at least as GREAT as that supported by the COMPILER in all contexts. An extended alignment is GREATER than the alignment of max_align_t type. A type having an extended alignment requirement is also CALLED over ALIGNED.

27.

_________ gives receipt of an interactive attention signals.(a) SIGILL(b) SIGTERM(c) SIGINT(d) SIGFPEI had been asked this question by my college director while I was bunking the class.I'm obligated to ask this question of Signal Handling in division C Library of C

Answer»

Correct ANSWER is (C) SIGINT

The EXPLANATION: SIGINT GIVES receipt of an INTERACTIVE attention signals.

28.

The macro MB_LEN_MAX is used to find _________(a) Maximum number of bytes in a multi-byte character(b) Whether the given function is valid or not(c) The maximum time taken for the execution of a particular function(d) Maximum number of bits in a multi-byte characterThis question was addressed to me during a job interview.My question is based upon Implementation-Defined Limits in chapter C Library of C

Answer» RIGHT option is (a) Maximum NUMBER of bytes in a multi-byte CHARACTER

For explanation: The MACRO MB_LEN_MAX is defined under the header FILE limits.h and is used to find the maximum number of bytes in a multi-byte character.
29.

Which of the following format specifiers is used to specify whether the given time is in AM or PM?(a) %P(b) %I(c) %X(d) %pThe question was asked in an online interview.Enquiry is from Date and Time Function in division C Library of C

Answer» CORRECT answer is (d) %p

The best I can explain: %p (small letter) is used to specify WHETHER the given time is in AM or PM. %I is used to represent the number of hours in the 12 HOUR clock format. %X is used to represent the standard time zone.
30.

Which is the true statement with respect to the function longjmp()?(a) the function where setjmp() was called has terminated, then the results are undefined(b) the function where setjmp() was called has terminated, then the results are defined(c) the function where jmp_buf was called has terminated, then the results are undefined(d) the function where jmp_buf was called has terminated, then the results are definedI got this question by my school principal while I was bunking the class.My question comes from Non-Local Jumps topic in chapter C Library of C

Answer»

Right answer is (a) the function where setjmp() was called has terminated, then the results are undefined

Easy EXPLANATION - The longjmp() function restores the environment saved by the most recent invocation of the SET jmp MACRO in the same invocation of the program, with the CORRESPONDING jmp buf ARGUMENT. The behavior is undefined, if there has been no such invocation, or if the function containing the invocation of the setjmp() macro has terminated execution in the interim.

31.

Select the correct declaration of setjmp().(a) int setjmp(jmp_buf environment)(b) int setjmp(long_jmp environment)(c) int setjmp(jmp_buf )(d) int setjmp(long_jmp)I got this question in unit test.Question is taken from Non-Local Jumps in chapter C Library of C

Answer»

Correct answer is (a) INT SETJMP(jmp_buf ENVIRONMENT)

EXPLANATION: Declaration of the macro setjmp() is int setjmp(jmp_buf environment). ’environment’ is a the OBJECT of type jmp_buf.

32.

Which of the following header file defines one function longjmp(), and one variable type jmp_buf?(a) stdarg.h(b) locale.h(c) setjmp.h(d) stdlib.hI had been asked this question in an interview.This key question is from Non-Local Jumps topic in portion C Library of C

Answer»

Correct CHOICE is (c) setjmp.h

Explanation: setjmp.h HEADER file defines the macro setjmp(), one FUNCTION longjmp(), and one VARIABLE type jmp_buf.

33.

LC_COLLATE affects strcoll() and strxfrm() functions.(a) true(b) falseThis question was addressed to me in an interview for job.The above asked question is from Localization topic in section C Library of C

Answer»

Correct choice is (a) true

The best I can EXPLAIN: LC_COLLATE is the MACRO defined under header FILE locale.h. It AFFECTS strcoll() and strxfrm() functions.

34.

Which macro saves the current environment into the variable environment for later use by the function longjmp().(a) setjmp(b) longjmp(c) jmp(d) set_jmpThe question was posed to me in unit test.The origin of the question is Non-Local Jumps topic in chapter C Library of C

Answer» RIGHT choice is (a) SETJMP

Explanation: The setjmp() macro SAVES its CALLING environment in its jmp-buf argument to be used later by the LONGJMP() function.
35.

Which among the given macros is defined in the header file locale.h?(a) SCHAR_MAX(b) FLT_RADIX 2(c) EDOM(d) LC_CTYPEThe question was asked at a job interview.This interesting question is from Localization topic in chapter C Library of C

Answer» CORRECT answer is (d) LC_CTYPE

Easiest explanation - LC_CTYPE is the macro defined under header file locale.h. This macro AFFECTS all CHARACTER FUNCTIONS.
36.

_____________ defines the minimum value for a short integer.(a) SHINT_MIN(b) SHRT_MIN(c) SINT_MIN(d) SHORT_MINI have been asked this question by my school teacher while I was bunking the class.This intriguing question comes from Implementation-Defined Limits topic in portion C Library of C

Answer»

The correct CHOICE is (b) SHRT_MIN

Easiest explanation - to DEFINE the MINIMUM value for a short integer, we USE the macro SHRT_MIN (defined under the header FILE limits.h).

37.

Which of the following is the correct description of the macro SIGFPE?(a) erroneous arithmetic operation such as zero divide(b) invalid access to storage(c) termination request sent to the program(d) receipt of the interactive attention signalThe question was asked in an interview for internship.My query is from Signal Handling in division C Library of C

Answer»

The CORRECT answer is (a) erroneous arithmetic operation such as ZERO DIVIDE

To EXPLAIN I would say: SIGFPE is the MACRO defined under the header file signal.h which is an erroneous arithmetic operation such as zero divide, or operation resulting in overflow.

38.

The macro __________ defines the number of bits in a byte, which is equal to _______(a) CHAR_BIT, 4(b) CHAR_BYTE, 8(c) CHAR_BIT, 8(d) CHAR_BYTE, 4I got this question during an interview.My question is based upon Implementation-Defined Limits topic in section C Library of C

Answer»

The CORRECT choice is (C) CHAR_BIT, 8

To explain I WOULD SAY: The macro CHAR_BIT defines the number of bits in a byte, which is equal to 8.

39.

Which of the following format specifiers is used to represent the hours in the 24 hour clock (0-23) format?(a) %I(b) %H(c) %i(d) %hI had been asked this question in an interview for job.My question is taken from Date and Time Function topic in section C Library of C

Answer»

Right CHOICE is (B) %H

The EXPLANATION: %H is a format specifier used to represent the number of HOURS in 24 hour clock format.

40.

Which of the following is not defined under the header file stddef.h?(a) size_t(b) ptrdiff_t(c) exp_t(d) nullThe question was posed to me in exam.Query is from Standard Definition in portion C Library of C

Answer»

Right answer is (C) exp_t

Easiest EXPLANATION - size_t, ptrdiff_t and NULL are defined under the file stddef.h. There is no type called exp_t c LANGUAGE.

41.

What are the contents of the register?(a) sp, fp only(b) sp only(c) fp, pc only(d) sp, fp, pcI had been asked this question in unit test.My question is taken from Non-Local Jumps in division C Library of C

Answer»

Right OPTION is (d) SP, fp, pc

Explanation: The contents of the registers includes sp, fp and cp. sp, fp and pc STANDS for stack pointer, frame pointer, and program COUNTER.

42.

Which of the following returns a signed integer type on finding the difference between two pointers to elements in the same array?(a) __cptrdiff__(b) cptrdiff_t(c) __ptrdiff__(d) ptrdiff_tI had been asked this question at a job interview.My question is from Standard Definition in portion C Library of C

Answer»

Correct option is (d) ptrdiff_t

To EXPLAIN I would SAY: ptrdiff_t is used for POINTER ARITHMETIC and array indexing. Only pointers to ELEMENTS of the same array may be subtracted from each other.

43.

To find the maximum value of an object of type unsigned long long int, we use the macro _________(a) ULINT_MAX(b) ULLINT_MAX(c) ULONG_MAX(d) ULLONG_MAXThis question was posed to me in unit test.I would like to ask this question from Implementation-Defined Limits in portion C Library of C

Answer»

Correct choice is (d) ULLONG_MAX

Easy EXPLANATION - The MACRO ULLONG_MAX is used to FIND the maximum value of unsigned long long int type. The macro ULONG_MAX is used to find the maximum value of unsigned long type.

44.

Which of the following format specifiers is used to represent the name of the time zone?(a) %A(b) %B(c) %H(d) %ZThe question was posed to me during an interview.My query is from Date and Time Function in portion C Library of C

Answer»

The correct option is (d) %Z

The explanation: The FORMAT specifier %Z is used to SPECIFY the name of the time zone. %A- FULL weekday, %B- full MONTH name, %H-hours(0-23).

45.

The value of CHAR_MAX will be equal to SCHAR_MAX when _________(a) char represents positive value(b) char represents value equal to 0(c) char represents negative value(d) char represents an exponential valueI got this question in exam.This interesting question is from Implementation-Defined Limits in section C Library of C

Answer» RIGHT option is (c) char REPRESENTS negative VALUE

The BEST I can explain: The macro CHAR_MAX defines the maximum value for type char and its value is equal to SCHAR_MAX is char represents negative value, otherwise UCHAR_MAX.
46.

The sig argument specifies the signal, which may be any signal except _______ and _________(a) SIG_DFL, SIG_IGN(b) SIGKILL, SIGSTOP(c) SIG_KILL, SIG_STOP(d) SIGCHLD, SIG_IGNThis question was posed to me in an interview for job.The query is from Signal Handling in section C Library of C

Answer»

The correct ANSWER is (b) SIGKILL, SIGSTOP

Explanation: The sigset() function is USED to MODIFY signal dispositions. The SIG argument specifies the signal, it can be any signal except SIGKILL and SIGSTOP.

47.

size_t is of ______________ type.(a) signed integer(b) signed character(c) unsigned integer(d) unsigned characterI had been asked this question in an online interview.Query is from Standard Definition topic in division C Library of C

Answer»

Correct option is (c) unsigned INTEGER

Explanation: size_t, defined under stddeh, is of the type unsigned integer. It is RETURNED by the SIZEOF() OPERATOR.

48.

The macro which is used to find the maximum value of an unsigned integer is _________(a) UNINT_MAX(b) UNSINT_MAX(c) UINT_MAX(d) UNIT_MAXI had been asked this question during an internship interview.Question is taken from Implementation-Defined Limits topic in portion C Library of C

Answer» RIGHT ANSWER is (c) UINT_MAX

Easy explanation - The macro which is USED to define the maximum value on an unsigned INTEGER is: UINT_MAX. To find the maximum value on a signed integer, we use the macro: SINT_MAX.
49.

The value returned by the library function mktime(), on failure is _________(a) -1(b) 0(c) 1(d) -2This question was posed to me by my school teacher while I was bunking the class.Asked question is from Date and Time Function topic in chapter C Library of C

Answer»

The CORRECT choice is (a) -1

Easy EXPLANATION - The library function mktime() converts the date and TIME into calendar FORMAT and returns the value -1 on the failure of this action.

50.

What is the type declared by the header file signal.h?(a) sig_atomic_t(b) sig_signal_t(c) sig_signal_h(d) sig_stomic_hI had been asked this question during a job interview.I need to ask this question from Signal Handling topic in chapter C Library of C

Answer»

The CORRECT ANSWER is (a) sig_atomic_t

The EXPLANATION is: The only type declared in signal.h is sig_atomic_h.

This is of int type and USED as a variable in signal HANDLING.