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.

101.

The cos function computes the cosine of x.(a) measured in radians(b) measured in degrees(c) measured in gradian(d) measured in milliradianThis question was addressed to me in an online interview.Enquiry is from Mathematical functions topic in section C Library of C

Answer»

Right answer is (a) measured in radians

To EXPLAIN: The cos FUNCTION COMPUTES the COSINE of x (measured in radians).

102.

Which of the following header declares mathematical functions and macros?(a) math.h(b) assert.h(c) stdmat. h(d) stdio. hThe question was asked in exam.I want to ask this question from Mathematical Functions in chapter C Library of C

Answer»

The CORRECT option is (a) math.h

Explanation: The header file math.h DECLARES all the MATHEMATICAL FUNCTIONS and macros.

103.

If access to the varying arguments is desired then the called function shall declare ________ having type va_list.(a) class(b) object(c) function(d) variableI had been asked this question in a national level competition.My enquiry is from Variable Argument Lists in division C Library of C

Answer»

The correct option is (b) OBJECT

Best EXPLANATION: An object of TYPE va_list has to be created in order to ACCESS the varying ARGUMENTS.

104.

void free(void *p) performs which of the following functions?(a) returns pointer to allocated space for existing contents of p(b) de-allocates space to which p points(c) to abnormally terminate the program(d) no such function defined in stdlib.hI have been asked this question by my college director while I was bunking the class.This intriguing question comes from General Utilities topic in section C Library of C

Answer» CORRECT option is (b) de-allocates SPACE to which p POINTS

Explanation: void FREE(void *p);

This FUNCTION de-allocates space to which p points(if p is not NULL).
105.

Which of the given function is used for searching?(a) lsearch()(b) bsearch()(c) csearch()(d) qsearch()This question was posed to me during an interview for a job.My doubt is from General Utilities in chapter C Library of C

Answer»

The correct answer is (b) bsearch()

To EXPLAIN I WOULD say: bsearch() FUNCTION is USED tosearch an array of objects, the initial ELEMENT is pointed by base, for an element that matches the object is pointedby key. The size of each element of the array is specified by size.

106.

Which of the following functions decomposes the input string into three pans: an initial, possibly empty, sequence of white-space characters?(a) strtod()(b) atof()(c) atol()(d) strtol()The question was posed to me in examination.Question is taken from General Utilities in chapter C Library of C

Answer» CORRECT answer is (d) strtol()

EASY explanation - The strtol() function is used to convert the initial portion of the string pointed to by, to long int REPRESENTATION. First, it decomposes the input string into three PANS: an initial, empty, white-space characters (as specified by the isspace function).
107.

The header file assert.h of the C Standard Library defines ________ macro.(a) stderr(b) stdarg(c) setjmp(d) assertThis question was posed to me in an interview.This intriguing question originated from Diagnostics topic in portion C Library of C

Answer»

Right answer is (d) assert

The best I can explain: The header file assert.h of the C Standard Library defines a macro CALLED assert is used to verify assumptions made by the program and PRINT a DIAGNOSTIC message if this ASSUMPTION is false.

108.

The abs() function computes the absolute value __________(a) a floating number(b) an integer number(c) a double number(d) all of the mentionedI got this question at a job interview.The above asked question is from General Utilities topic in section C Library of C

Answer»

The correct choice is (B) an integer number

The explanation: int abs (int i);

The abs() FUNCTION is used to COMPUTE the ABSOLUTE value of an integer i. If the result cannot be REPRESENTED, the behavior is undefined.

109.

Select the right statement with reference to malloc() and calloc().(a) malloc() does not set the memory to zero whereas calloc() sets allocated memory to zero(b) malloc() sets the memory to zero whereas calloc() does not set allocated memory to zero(c) malloc() sets the memory to zero whereas calloc() sets allocated memory to zero(d) malloc() does not set the memory to zero whereas calloc() does not set allocated memory to zeroI have been asked this question during an interview.My question comes from General Utilities topic in chapter C Library of C

Answer»

The correct choice is (a) malloc() does not SET the memory to zero WHEREAS calloc() SETS allocated memory to zero

To EXPLAIN: The DIFFERENCE in malloc() and calloc() is that calloc() sets the memory to zero whereas malloc()does not sets allocated memory to zero.

110.

The C library macro type _________ retrieves the next argument in the parameter list of the function with type.(a) va_end(b) va_arg(c) va_start(d) no macrosThe question was asked during an interview.This is a very interesting question from Variable Argument Lists in division C Library of C

Answer»

The CORRECT answer is (B) va_arg

For explanation: va_arg is the C LIBRARY macro defined under stdarg.h which RETRIEVES the next argument in the PARAMETER list of the function.

111.

Which of the given option is declared under the header file stdlib.h?(a) SEEK_CUR(b) SEEK_END(c) CLOCKS_PER_SEC(d) EXIT_SUCCESSThis question was addressed to me in an interview for job.Question is taken from General Utilities topic in portion C Library of C

Answer»

Correct ANSWER is (d) EXIT_SUCCESS

To explain: SEEK_CUR and SEEK_END is DEFINED under stdio.h, CLOCKS_PER_SEC is defined under time.h, EXIT_SUCCESS is defined under stdlib.h.

EXIT_SUCCESS specifies value for status argument to exit INDICATING SUCCESS.

112.

What members do the structure returned by function div() contains?(a) int quot and int rem(b) float quot and float rem(c) double quot and double rem(d) no members are returned by div()I got this question during an interview.My question is from General Utilities in portion C Library of C

Answer»

Correct option is (a) int quot and int rem

Easy explanation - A structure of type div_t is returned by the FUNCTION DIV(), contains both the QUOTIENT and the REMAINDER. The structurecontains two members,

 int quot; /* quotient */

int rem; /* remainder */

113.

Which among thegiven function causes abnormal program termination ?(a) exit()(b) abort()(c) atexit()(d) getenv()I got this question by my college professor while I was bunking the class.Question is from General Utilities topic in section C Library of C

Answer»

Right answer is (b) ABORT()

To EXPLAIN I would say: void abort (void);

The abort() function causes ABNORMAL PROGRAM termination to OCCUR, and comes out directly from that place.

114.

Which of the given function converts the string pointed to, by the argument str to a floating-point number?(a) atof(const char *str)(b) strtod(const char *str, char **endptr)(c) atoi(const char *str)(d) atol(const char *str)The question was posed to me during an online interview.This interesting question is from General Utilities in chapter C Library of C

Answer»

Correct CHOICE is (a) atof(const char *STR)

The explanation is: The atof function converts the initial portion of the string pointed to by str to double representation. Except for the behavior on the error, it is equivalent to strtod (nptr, (char **)NULL).

115.

Which of the following is the correct code?(a) tanh(double x)(b) tanh double x(c) tanhdouble x(d) tanhdoublexThis question was addressed to me in exam.My question comes from Mathematical functions in portion C Library of C

Answer»

Right choice is (a) tanh(DOUBLE X)

The EXPLANATION: The correct code is tanh(double x). The tanh() function computes the HYPERBOLIC TANGENT of x.

116.

All the functions in this library take as a parameter and return as the output.(a) double, int(b) double, double(c) int, double(d) int, intThe question was asked in unit test.This key question is from Mathematical Functions in section C Library of C

Answer» CORRECT choice is (B) double, double

Easy explanation - All the function in this MATH library takes double as a PARAMETER and GIVES double as the result.
117.

If the expression in void assert(int expression) is zero then a message is printed on stderr(standard error file).(a) true(b) falseThe question was posed to me in semester exam.The origin of the question is Diagnostics topic in division C Library of C

Answer»

The correct answer is (a) true

The EXPLANATION is: When the EXPRESSION in the macro void ASSERT(INT expression) is zero then the macro DISPLAYS error message on stderr.

118.

The ldexp() function multiplies a floating-point number by an integral power of 2.(a) true(b) falseThe question was posed to me during an interview.This intriguing question comes from Mathematical functions in chapter C Library of C

Answer»

Correct choice is (a) true

Easy explanation - double ldexp(double X, int exp);

The ldexp function multiplies a floating-point number by an integral POWER of 2. A range error may OCCUR. The ldexp() function RETURNS the value of x times 2 raised to the power exp.

119.

How many macros are defined in the header file stdarg.h?(a) one(b) two(c) three(d) fourThe question was posed to me by my college professor while I was bunking the class.I would like to ask this question from Variable Argument Lists in section C Library of C

Answer»

The CORRECT choice is (C) three

The BEST I can explain: The HEADER file stdarg.h has three macros DEFINED in it.

120.

If NDEBUG is defined as a macro name, at the point where is included, then assert macro is defined as #define assert(ignore) ((void)0).(a) true(b) falseThis question was addressed to me by my school principal while I was bunking the class.Enquiry is from Diagnostics topic in section C Library of C

Answer» RIGHT answer is (a) true

The BEST I can explain: If NDEBUG is defined as a macro name at the point in the SOURCE file WHEREIS included, then the assert macro is defined as #define assert(ignore) ((void)0) .
121.

The mbstowcs() function is used to return the number of array elements modified, not including a terminating zero code, if any.(a) true(b) falseThe question was asked in final exam.The origin of the question is General Utilities topic in division C Library of C

Answer»

Right answer is (a) true

The EXPLANATION: mbstowcs() function RETURNS the number of array elements that are modified. It does not return a terminating zero code if any. The mbstowcs() function is used to convert a SEQUENCE of MULTIBYTE characters that begins in the initial SHIFT state from the array pointed to by, into a sequence of corresponding codes.

122.

Which function will return the quotient and remainder on division of numerator with denominator?(a) div()(b) div_t()(c) ldiv_t()(d) labs()I have been asked this question during an internship interview.My doubt is from General Utilities topic in chapter C Library of C

Answer»

Correct OPTION is (a) div()

To explain: div_t div(int num, int den);

The div () function is USED to COMPUTE the QUOTIENT and remainder of the division of the NUMERATOR num by the denominator den.div_t is the structure which contains a quotient member and a remainder member.

123.

What is returned by the function if the space cannot be allocated by the function malloc(), realloc() and calloc()?(a) value(b) error(c) null pointer(d) no valueThe question was asked in an internship interview.I would like to ask this question from General Utilities topic in chapter C Library of C

Answer»

The correct CHOICE is (c) NULL pointer

To explain: The pointer returned points to the lowest BYTE address of the allocated space. A null pointer is returned, if the space cannot be allocated.

124.

Which of the following is the correct syntax of the function strtoul()?(a) unsigned long int strtoul(const char *n, char **ptr, int base)(b) unsigned long int strtoul(const char *n, char **ptr)(c) unsigned long int strtoul(const char *n)(d) int strtoul(const char *n)I had been asked this question during a job interview.The query is from General Utilities topic in portion C Library of C

Answer» RIGHT choice is (a) unsigned long int strtoul(const char *n, char **ptr, int base)

EXPLANATION: usigned long int strtoul(conmt char *n, char **ptr, int base); The strtoul() function is used to CONVERT the initial portion of the string pointed to by n to unsigned long int REPRESENTATION.
125.

The______function is used to convert the initial portion of the string pointed to by, to unsigned long int representation.(a) strtod()(b) atol()(c) strtoul()(d) strtol()The question was posed to me in homework.I'm obligated to ask this question of General Utilities in chapter C Library of C

Answer»

Right choice is (c) strtoul()

To EXPLAIN: UNSIGNED long INT strtoul(const char *p, char **PTR, int base) function is used toconvert the initial part of the string in p to an unsigned long int value ACCORDING to the given base,it must be between 2 and 36 inclusive, or be the special value 0.

126.

sqrt(x) function is not faster than the apparent equivalent pow(x,0.5).(a) true(b) falseThis question was addressed to me during a job interview.This interesting question is from Mathematical functions in division C Library of C

Answer»

Correct choice is (b) false

Easiest EXPLANATION - sqrt(X) function is generally much faster than the APPARENT equivalent POW (x, 0.5).

127.

The function computes the exponential function of x.(a) exp(x)(b) frexp(x)(c) frexp x(d) exp xI had been asked this question in quiz.My enquiry is from Mathematical functions in portion C Library of C

Answer»

Right answer is (d) EXP X

The best I can EXPLAIN: The exp(x) FUNCTION computes the exponential function of x.

128.

The function computes the hyperbolic cosine of x.(a) cos(x)(b) cosine(x)(c) cosh(x)(d) cosineh(x)I have been asked this question in examination.My doubt stems from Mathematical functions topic in division C Library of C

Answer»

The correct option is (c) cosh(X)

To explain I would SAY: The cosh() function computes the HYPERBOLIC cosine of x. The cosh function returns the hyperbolic cosine VALUE.

129.

If the result underflow, the function returns zero.(a) true(b) falseThe question was posed to me by my school teacher while I was bunking the class.I'm obligated to ask this question of Mathematical Functions in section C Library of C

Answer»

The correct CHOICE is (a) true

The BEST I can explain: If the RESULT UNDERFLOWS i.e the magnitude of the result is very small to be represented in an object of the specified type, the function RETURNS zero.

130.

Which of the given statement is true with respect to the function atexit()?(a) The atexit() function cannot return to its caller(b) The atexit() functionis used to return zero if the registration succeeds, nonzero if it fails(c) The atexit() function returns no value(d) The atexit() function causes abnormal program termination to occurThe question was asked during an interview for a job.My question is based upon General Utilities in division C Library of C

Answer»

The correct answer is (b) The atexit() functionis used to return ZERO if the registration succeeds, nonzero if it fails

Easiest EXPLANATION - The prototype of FUNCTION isint atexit (void (*FUNC) (void) );

The atexit() function is used to register the function POINTED to by func, to be called without arguments at normal program termination.

131.

RAND_MAX macro is the maximum value returned by the rand function.(a) true(b) falseThis question was posed to me in quiz.Question is taken from General Utilities in chapter C Library of C

Answer»

Correct answer is (a) true

Easiest explanation - RAND_MAX is the macro which EXPANDS to an INTEGRAL constant EXPRESSION, the value of which is the maximum value RETURNED by the rand function.