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.

51.

Select the right statement.(a) synchronous signal occurs because of the action that your program takes(b) synchronous signal occurs because of action outside your program(c) asynchronous signal occurs because of the action that your program takes(d) division by zero is asynchronousI had been asked this question in an interview.Question is from Signal Handling in section C Library of C

Answer»

Right option is (a) SYNCHRONOUS signal OCCURS because of the ACTION that your PROGRAM takes

The best explanation: Synchronous signal occurs because of the ACTIONS that your program takes.

52.

How many times can the macro setjmp() return?(a) one time(b) two times(c) three times(d) many timesI had been asked this question in class test.The question is from Non-Local Jumps topic in section C Library of C

Answer»

The correct choice is (b) two times

Easiest explanation - SETJMP() macro returns twice. FIRST time, setjmp() returns ZERO on its DIRECT invocation. Second time macro returns when longjmp is called with the information written to the environment; now, it returns the VALUE passed to longjmp as second argument.

53.

Which of the following macros is not defined?(a) ULONG_MIN(b) LONG_MIN(c) ULONG_MAX(d) LONG_MAXThe question was posed to me by my college director while I was bunking the class.The above asked question is from Implementation-Defined Limits in section C Library of C

Answer»

The CORRECT answer is (a) ULONG_MIN

Best EXPLANATION: The macro ULONG_MIN is not defined WHEREAS the macros LONG_MIN, ULONG_MAX and LONG_MAX are all defined in the header FILE limits.h.

54.

Which of the given statement is not true with respect to void longjmp( jmp-buf env, int val)?(a) The variable value cannot be zero(b) env is the object containing information to restore the environment at the jmp_buf’s calling point(c) This function does not return any value(d) This function restores the environment saved by the most recent call to setjmp() macroThe question was asked in unit test.My doubt stems from Non-Local Jumps in portion C Library of C

Answer» CORRECT OPTION is (b) env is the object containing information to restore the environment at the jmp_buf’s calling point

To explain: In the FUNCTION VOID LONGJMP( jmp-buf env, int val), env is the object containing information to restore the environment at the setjmp’s calling point.
55.

What is the function of the given longjump(jmp_buf buf, i)?(a) go back to place buf is pointing to and return i(b) go back to place buf is pointing to and return 0(c) uses buf to remember current position and returns 0(d) uses buf to remember current position and returns iI have been asked this question in an interview for internship.I'd like to ask this question from Non-Local Jumps in portion C Library of C

Answer» RIGHT answer is (a) go back to PLACE buf is pointing to and RETURN i

Explanation: In the given function longjmp(jmp_buf buf,i), it goes back to place buf is pointing to and return i.setjmp(jmp_bufbuf) uses buf to remember current position to and return 0.
56.

Select the macro that abnormally terminates the program.(a) SIGILL(b) SIGTERM(c) SIGABRT(d) SIGFPEI had been asked this question in an interview.My enquiry is from Signal Handling topic in portion C Library of C

Answer»

Correct option is (c) SIGABRT

The best I can EXPLAIN: SIGABRT is the macro DEFINED under the header file signal.h which terminates the program ABRUPTLY.

57.

Which function restores the environment saved by the most recent invocation of the setjmp() macro in the same invocation of the program?(a) jmp_buf(b) longjmp(c) jmpbuf(d) long_jmpI got this question during an internship interview.Origin of the question is Non-Local Jumps topic in portion C Library of C

Answer»

Right OPTION is (b) LONGJMP

Explanation: longjmp() is the only function defined under the HEADER file SETJMP.h. What setjmp() does is save the contents of the registers so that longjmp() can restore the contents later.

58.

Which macro affects the strftime() function?(a) LC_TIME(b) LC_SEC(c) LC_MIN(d) LC_SETThis question was addressed to me in my homework.Enquiry is from Localization in portion C Library of C

Answer»

The correct OPTION is (a) LC_TIME

For EXPLANATION: LC_TIME is the macro DEFINED under locale. h which affects the STRFTIME() function.

59.

Which of the given options is an array type used for holding information?(a) longjmp(b) setjmp(c) jmp_buf(d) no such variableI got this question during an internship interview.My doubt is from Non-Local Jumps topic in portion C Library of C

Answer» RIGHT option is (c) jmp_buf

Explanation: jmp_buf is an ARRAY TYPE used for holding information of macro setjmp() and function longjmp().This is a VARIABLE type defined under the header file setjmp.h.
60.

The macro offset expands to a constant of type __________________(a) size_t(b) print_t(c) ptrdiff_t(d) nullThis question was posed to me in class test.Query is from Standard Definition in division C Library of C

Answer»

The CORRECT CHOICE is (a) size_t

Easiest explanation - offsetof EXPANDS to a constant of TYPE size_t. It retuns the offset of the FIELD member from the start to of the structure type.

61.

The three macros defined by stdarg.h is _________(a) start(), arg() and end()(b) var_start(), var_arg() and var_end()(c) va_start(), va_arg() and va_end()(d) v_start(), v_arg() and v_end()The question was asked by my college professor while I was bunking the class.My question is from Variable Argument Lists in division C Library of C

Answer»

Right option is (C) va_start(), va_arg() and va_end()

Best EXPLANATION: The header file stdarg.h has three MACROS defined in it. They are va_start(), va_arg() and va_end(). va_listis a VARIABLE TYPE that holds information needed by the three macros.

62.

What is the name of the macro that is referred by assert macro defined in assert .h?(a) STDARG(b) SETJMP(c) NDEBUG(d) STDERRI got this question in quiz.Query is from Diagnostics topic in division C Library of C

Answer»

The CORRECT choice is (C) NDEBUG

For explanation: The header FILE defines the assert MACRO and refers to another macro, NDEBUG which is not DEFINED by .

63.

The behavior is undefined if more than one call to the exit function is executed by a program.(a) true(b) falseThe question was asked during an interview for a job.Asked question is from General Utilities topic in section C Library of C

Answer» CORRECT CHOICE is (a) true

Easy explanation - The EXIT() function causes normal program termination to occur. The BEHAVIOR is undefined if more than one call to the exit function is executed by a program.
64.

double ______ (double x, double y) computes the floating-point remainder of x/y.(a) modf(b) fmod(c) ceil(d) floorThe question was posed to me in final exam.This key question is from Mathematical functions topic in chapter C Library of C

Answer» CORRECT ANSWER is (b) FMOD

Explanation: double fmod(doublr x, double y);

The fmod() FUNCTION computes the floating-point remainder of x/y.
65.

Which of the given function differs from the statement’errno is not neccessarily set on conversion error’?(a) atof()(b) atoi()(c) atol()(d) strtod()This question was posed to me by my school principal while I was bunking the class.My question comes from General Utilities topic in division C Library of C

Answer»

The correct option is (d) strtod()

EASY explanation - The function ATOI() and ATOL() are similar to strtol(), atof() is similar to strtod() except that errono is not necessarily set on CONVERSION error.

66.

Which function is called repeatedly by bsearch() to compare search elements against the elements in the array?(a) mblem()(b) wctomb()(c) compar()(d) labs()I got this question during an interview.I would like to ask this question from General Utilities topic in division C Library of C

Answer»

Right option is (c) compar()

To EXPLAIN: void *bsearch(CONST void *key, const void *base, size_t nitems, size_t size, int (*compar)(const void *, const void *))

The COMPARISON function POINTED to by compar() is called with two arguments that point to the key object to be searched and to an array element, in that order. The function shall return a < 0, = 0, or > 0 if the key object is CONSIDERED, respectively, to be less than, to match, or to be greater than the array element.

67.

The_______function converts the initial portion of the string pointed to by, to int representation.(a) atof()(b) atoi()(c) strtod()(d) atol()This question was posed to me in an interview for job.Asked question is from General Utilities topic in section C Library of C

Answer»

Right option is (B) atoi()

The best explanation: int atoi(const CHAR *str); The C library FUNCTION int atoi(const char *str) converts the STRING argument str to an integer (type int).

68.

Name the function that breaks a floating-point number into a normalized fraction and an integral power of 2.(a) exp()(b) frexp()(c) Idexp()(d) modf()I have been asked this question in a job interview.This is a very interesting question from Mathematical functions in chapter C Library of C

Answer»

Correct ANSWER is (b) frexp()

For EXPLANATION: The frexp() function breaks a floating-point number into a normalized fraction and an INTEGRAL power of 2.

69.

Whichmacro retrieves the next argument in the parameter list of the function with type type?(a) type va_arg(va_list ap, type)(b) type var_arg(va_list ap, type)(c) type v_arg(va_list ap, type)(d) type val_arg(va_list ap, type)This question was posed to me by my school principal while I was bunking the class.I want to ask this question from Variable Argument Lists topic in section C Library of C

Answer»

Correct ANSWER is (a) TYPE va_arg(va_list ap, type)

The best I can explain: type va_arg(va_list ap,type)

This macro is used to retrieve the next argument in the parameter list of the FUNCTION with type type.

70.

Which is the correct declaration of macro assert?(a) void assert(int expression);(b) void assert(float expression);(c) void assert(double expression);(d) void assert( expression);The question was asked in class test.My question is based upon Diagnostics in chapter C Library of C

Answer» CORRECT answer is (a) VOID assert(INT expression);

To explain: The RIGHT declaration of the macro assert DEFINED under the header file assert.h is void assert(int expression), expression can be any variable.
71.

The number of bytes contained in the multibyte character pointed to by a character is ___________(a) getenv()(b) bsearch()(c) mblen()(d) qsort()This question was addressed to me at a job interview.Enquiry is from General Utilities in portion C Library of C

Answer»

Correct answer is (c) mblen()

To explain I would say: int mblen(const char *s, size-t n);

If s is not a NULL pointer, the mblen() FUNCTION is USED to determine the number of BYTES contained in the multibyte character POINTED to by s.

72.

_______variable type defined in the header stdlib.h is an integer type of the size of a wide character constant.(a) size_t(b) wchar_t(c) div_t(d) ldiv_tI had been asked this question during an online exam.I need to ask this question from General Utilities in portion C Library of C

Answer»

Correct option is (b) wchar_t

Explanation: wchar_t

This is an INTEGER type of the SIZE of a WIDE CHARACTER CONSTANT defined under the header stdlib.h .

73.

A range error occurs if the result of the function cannot be represented as a value.(a) int(b) short int(c) double(d) floatI had been asked this question during an interview for a job.Query is from Mathematical Functions in chapter C Library of C

Answer» RIGHT OPTION is (c) DOUBLE

Explanation: if the result of the function cannot be REPRESENTED as a double value, a range error OCCURS. If the result overflows (the magnitude of the result is so large that it cannot be represented in an object of the specified type), the function returns the value of the macro HUGE_VAL, with the same sign as the correct value of the function.
74.

The assert macro returns__________value.(a) integer(b) float(c) double(d) noI had been asked this question in an internship interview.Enquiry is from Diagnostics in section C Library of C

Answer»

Right option is (d) no

To EXPLAIN: No VALUE is returned by the MACRO assert.

75.

void free(void *ptr) deallocates the memory previously allocated by a call to _______________or _________(a) malloc,getenv,abort(b) calloc,malloc,exit(c) calloc,malloc,realloc(d) exit,getenv,abortThis question was posed to me in an interview for internship.Asked question is from General Utilities in division C Library of C

Answer»

Correct option is (c) calloc,MALLOC,realloc

To explain I would SAY: The free() function causes the space to be deallocated that are pointed to by ptr, that is, made AVAILABLE for further allocation. No action occurs if ptr is a null pointer. Otherwise, if the ARGUMENT does not match a pointer EARLIER returned by the calloc. malloc, or realloc function.

76.

Which of the given structure is returned by the function ldiv()?(a) div_t(b) ldiv_t(c) div_i(d) ldiv_iI had been asked this question in class test.The above asked question is from General Utilities topic in section C Library of C

Answer»

Right option is (B) ldiv_t

To explain: ldiv_t isthe structure returned by the function DIV(). ldiv() function is similar to the function div() EXCEPT that the argument and the returned VALUE is of type long int.

77.

The assert shall be implemented as a ______ not as an actual ________(a) function, macro(b) macro, function(c) header, macro(d) macro, headerI have been asked this question in an interview for internship.My doubt stems from Diagnostics topic in portion C Library of C

Answer»

Right OPTION is (b) macro, function

Explanation: assert shall be implemented as a macro and not a function, which is used to ADD DIAGNOSTICS information in your C PROGRAM. The behavior is undefined if the macro definition is suppressed to access an actual function.

78.

Choose the correct statement.(a) bsearch() returns no value to the function(b) getenv() returns no value to the function(c) qsort() returns no value to the function(d) realloc() returns no value to the functionThis question was addressed to me in exam.Asked question is from General Utilities topic in portion C Library of C

Answer» RIGHT OPTION is (c) qsort() returns no value to the function

The BEST I can explain: The qsort() function does not RETURN any value.
79.

Which of the following is the correct description of EXIT_FAILURE?(a) This is the value for the exit function to return in case of failure(b) This is the value for the exit function to terminate the program(c) This is the value for the exit function to return in case of success(d) This is the value for the exit function to return in case it is the maximum valueThis question was posed to me in an online interview.This intriguing question originated from General Utilities in chapter C Library of C

Answer»

The correct ANSWER is (a) This is the value for the exit function to return in case of failure

Easy explanation - The macros DEFINED is EXIT-FAILURE which expand to INTEGRAL expressions that may be used as the argument to the exit function to return unsuccessful.

80.

What error occurs if the magnitude of x is too large in sinh(double x)?(a) domain error(b) range error(c) no error(d) zero is returnedI got this question during an online exam.Enquiry is from Mathematical functions in section C Library of C

Answer»

Correct choice is (b) RANGE ERROR

The best explanation: The sinh() function computes the hyperbolic sine of X. A range error occurs if the magnitude of x is too large.If the RESULT OVERFLOWS i.e the magnitude of the result is too large to be represented in an object of the specified type).

81.

The _______ macro shall be invoked before any access to the unnamed arguments.(a) va_arg(b) va_end(c) va_list(d) va_startI got this question in an interview for job.My question is taken from Variable Argument Lists topic in chapter C Library of C

Answer»

The correct OPTION is (d) va_start

The best explanation: va_start macro SHALL be invoked before any ACCESS to the unnamed arguments.void va-start (va-list AP, p); The va-start macro initializes ap for subsequent USE by va-arg and va-end.

82.

The macro void assert(int expression) allows the diagnostic information to be written in which of the following files?(a) standard error file(b) output file(c) string file(d) character fileThis question was addressed to me in homework.My question is from Diagnostics in section C Library of C

Answer»

Right OPTION is (a) STANDARD error file

Best explanation: The macro assert prints diagnostic information on the standard error file(stderr). The assert macro WRITES the information about the particular call that failed (including the text of the argument, name of the SOURCE file and the source line NUMBER) on the standard error file in an implementation-defined format.

83.

A domain error occurs if x is negative and y is not an integral value for the function pow(double x, double y).(a) true(b) falseThis question was posed to me during a job interview.Enquiry is from Mathematical functions in division C Library of C

Answer»

The CORRECT answer is (a) true

Explanation: The pow() FUNCTION computes x raised to the power y. A domain error OCCURS if x is NEGATIVE and y is not an integral value. A domain error occurs if the result cannot be represented when x is zero and y is less than or equal to zero. A RANGE error may occur.

84.

The header file stdarg.h defines a variable type ________(a) va_list(b) v_list(c) size_t(d) var_listThe question was asked during an interview.This is a very interesting question from Variable Argument Lists topic in chapter C Library of C

Answer»

Correct OPTION is (a) va_list

Best explanation: The variable type declared under the HEADER file stdarg.h is va_list. This HOLDS information REQUIRED by three MACROS.

85.

The C library function _____________function converts the wide character to its multibyte representation.(a) mblen()(b) mbtowc()(c) wcstombs()(d) wctomb()This question was posed to me in semester exam.Enquiry is from General Utilities topic in division C Library of C

Answer»

Right option is (d) wctomb()

Explanation: wctomb() is a C Library FUNCTION which CONVERTS the wide character into its multibyte representation. It is stored at the beginning of the character array POINTED to by the respective pointer.

86.

What is the name of the function that is used to convert multibyte character to wide character?(a) mblen()(b) mbtowc()(c) mbstowcs()(d) wcstombs()The question was asked in homework.Query is from General Utilities topic in division C Library of C

Answer» CORRECT option is (b) mbtowc()

Explanation: mbtowc() FUNCTION is used to convert the multibyte CHARACTER to WIDE character.
87.

What is the function of the void *realloc(void *str, size-t size);?(a) allocates space for an array of str objects, each of whose size is size(b) allocates space for an object whose size is specified by size and whose value is indeterminate(c) changes the size of the object pointed to by str to the size specified by size(d) causes the space pointed to by str to be deallocated, that is, made available for further allocationThis question was addressed to me during an interview.My question is from General Utilities in chapter C Library of C

Answer»

Correct answer is (c) CHANGES the size of the object pointed to by STR to the size SPECIFIED by size

The explanation: void *REALLOC(void *str, size-t size);

The realloc() function is used to change the size of the object which is pointed to by str to the size specified by size.

88.

______ macro must be called before using ______ and ________(a) va_arg, va_end and va_start(b) va_start, va_end and va_arg(c) va_end, va_arg and va_start(d) v_arg, v_end and v_startThe question was posed to me at a job interview.This question is from Variable Argument Lists topic in portion C Library of C

Answer»

Correct choice is (B) va_start, va_end and va_arg

Explanation: va_start macro must be CALLED before using macros va_end and va_arg.

The macro VOID va_start(va_list p, last_arg) initializes p variable to be USED with the va_arg and va_end macros.

89.

The _______ function sorts an array of objects.(a) bsort()(b) hsort()(c) ssort()(d) qsort()The question was asked in an internship interview.This intriguing question comes from General Utilities in division C Library of C

Answer»

The correct choice is (d) qsort()

The explanation: void qsort(void *base, size_t nmemb, size_t size, int (*COMPAR)(const void *, const void*))

The qsort() function is used to SORT an array of nmemb objects, the initial ELEMENT of array is pointed to by base. The size of each object in array is specified by size. The contents of the array are sorted into ascending order ACCORDING to a comparison function pointed to by compar.

90.

A function is declared as sqrt(-x) under the header file math.h, what will the function return?(a) square root of x(b) complex number(c) domain error(d) range errorI got this question during an interview.This interesting question is from Mathematical functions topic in division C Library of C

Answer» CORRECT answer is (c) domain error

Explanation: double SQRT (double x);

The sqrt function computes the nonnegative SQUARE root of x. A domain error occurs if the argument is negative.
91.

void assert(int expression) when the expression is evaluated to true?(a) assert returns integer value(b) assert displays error message(c) assert returns nothing(d) assert displays patternThe question was posed to me in an online interview.This question is from Diagnostics in chapter C Library of C

Answer»

Correct CHOICE is (C) assert returns NOTHING

Easiest explanation - VOID assert(int expression), expression can be a variable or any C expression. If the expression EVALUATES to TRUE, assert() does nothing.

92.

Which function converts the wide-character string to a multibyte string?(a) wcstombs()(b) mbstowcs()(c) mbtowc()(d) mblen()This question was posed to me during an interview.This intriguing question originated from General Utilities topic in portion C Library of C

Answer»

Correct option is (a) wcstombs()

The best I can EXPLAIN: The C LIBRARY function size_t wcstombs(char *ptr, const wchar_t *ws, size_t N)is used to convert the wide-character string was to a multibyte string starting at ptr. At most n bytes are WRITTEN to ptr.

93.

The pointer used in the mblen() function points to the _________(a) first byte of multibyte character(b) last byte of multibyte character(c) middle byte of multibyte character(d) no pointer is used in mblen functionThis question was addressed to me in an online quiz.This interesting question is from General Utilities topic in chapter C Library of C

Answer» RIGHT choice is (a) FIRST byte of multibyte character

Best explanation: The PROTOTYPE of the functon mblen() is int mblen(const char *s,size_t N); The POINTER ‘s’ points to the first byte of the multibyte character.
94.

The ________ function returns no value.(a) malloc()(b) realloc()(c) free()(d) calloc()This question was addressed to me by my school teacher while I was bunking the class.My question comes from General Utilities in section C Library of C

Answer»

The correct option is (c) free()

Easiest explanation - The calloc() FUNCTION is used to return EITHER a null POINTER or a pointer to the allocated space. The malloc() function is used to return either a null pointer or a pointer to the allocated space. The realloc() function is used to return either a null pointer or a pointer to the possibly moved allocated space. The free() function returns no value.

95.

Which among the given function does not return a value?(a) strtoul()(b) strtol()(c) rand()(d) srand()The question was asked in semester exam.My question is taken from General Utilities in division C Library of C

Answer»

Right OPTION is (d) srand()

EXPLANATION: void srand(unsigned int seed);

The srand() function uses argument as a seed for a new SEQUENCE of pseudo-random numbers to be RETURNED by subsequent calls to rand(). The srand() function RETURNS no value.

96.

The calloc() function allocates space for an array of n objects, each of whose size is defined by size. Space is initialized to all bits zero.(a) true(b) falseI had been asked this question in class test.The origin of the question is General Utilities in portion C Library of C

Answer»

The correct option is (a) true

Explanation: VOID *calloc(size-t N, size-t size);

This FUNCTION is used to allocate the REQUESTED memory and returns a pointer to it.

97.

If the result overflows, the function returns the value of the macro HUGE_VAL, carrying the same sign except for the _________ function as the correct value of the function.(a) sin(b) cos(c) cosec(d) tanI have been asked this question by my school teacher while I was bunking the class.My enquiry is from Mathematical Functions in division C Library of C

Answer»

Correct choice is (d) TAN

The explanation: If the result overflows i.e the magnitude of the result is too large to be REPRESENTED in an object of the specified type, the function returns the value of the macro HUGE_VAL, with the same SIGN EXCEPT for the tan function as the correct value of the function.

98.

What error occurs if an input argument is outside the domain over which the mathematical function is defined?(a) domain error(b) range error(c) no error(d) domain and range errorThe question was posed to me by my college professor while I was bunking the class.My question is from Mathematical Functions topic in portion C Library of C

Answer»

Correct option is (a) DOMAIN ERROR

Explanation: A domain error occurs if an input argument is OUTSIDE the domain over which the MATHEMATICAL function is defined.

99.

HUGE_VAL macro is used when the output of the function may not be ___________(a) floating point numbers(b) integer number(c) short int(d) long intThe question was posed to me in an online interview.I'd like to ask this question from Mathematical Functions in division C Library of C

Answer»

Right option is (a) floating POINT numbers

The best I can EXPLAIN: HUGE_VAL macro is USED when the result of a FUNCTION may not be REPRESENTABLE as a floating point number.

100.

Which statement is true regarding abs() and labs()?(a) The abs() function is similar to the labs() function, except that the argument and the returned value each of them have type long int(b) The abs() function is not similar to the labs() function, except that the argument and the returned value in both functions have type long int(c) The abs() function is similar to the labs() function, except that the argument and the returned value each have type short int(d) The abs() function is not similar to the labs() function, except that the argument and the returned value in both function have type short intThe question was asked by my school teacher while I was bunking the class.My question is from General Utilities in portion C Library of C

Answer»

The correct answer is (a) The ABS() FUNCTION is similar to the labs() function, except that the argument and the RETURNED value each of them have type LONG INT

Easiest explanation - long int labs(long int i);

The abs() function is similar to the labs() function, except that the returned value and argument each are of type long int.