Machine-translated by Google. Questions are authored in English.
Top

Library Functions Questions and Answers

71.

Select the function that reads or sets location dependent information.

Answer: B

Correct answer: setlocale()

setlocale() reads or sets the program’s locale - the conventions for decimal points, currency, dates, character classification and collating order. Until it is called with something other than "C", a program uses the minimal default locale whatever the system is set to.

Please log in or register to report this question.

72.

The library function clock() returns the number of _________ elapsed since the start of the program.

Answer: B

Correct answer: clock ticks

clock() returns processor time in implementation-defined units, clock ticks. To get seconds, divide by CLOCKS_PER_SEC. Note that it measures processor time used, not elapsed wall-clock time, so a program that spends its time waiting shows very little.

Please log in or register to report this question.

73.

Some types and macros defined under the header file stddef.h may be defined under other header files too.

Answer: A

Correct answer: True

<stddef.h> defines size_t, ptrdiff_t, wchar_t, NULL and offsetof - and several of these are also defined by other headers, so that a program including <stdio.h> gets size_t and NULL without asking. Repeating an identical definition is harmless.

Please log in or register to report this question.

74.

mblen() function returns 0,if a null wide character was recognized. It returns -1 if an invalid multi-byte sequence was encountered.

Answer: A

Correct answer: true

mblen() returns 0 for a null character, -1 for an invalid multibyte sequence, and otherwise the number of bytes the character occupies. The three cases together are what let a program walk a multibyte string safely.

Please log in or register to report this question.

75.

The source filename and line number come from the preprocessor macros________and______

Answer: A

Correct answer: _ _FILE_ _ and _ _LINE_ _

__FILE__ expands to the current source file name as a string and __LINE__ to the current line number. They are what assert uses to report where a failure occurred, and they are indispensable in logging macros.

Please log in or register to report this question.

76.

_______variable type defined in the header stdlib.h is an integer type of the size of a wide character constant.

Answer: B

Correct answer: wchar_t

wchar_t is the integer type large enough to hold any character of the extended character set - the type of a wide character constant such as L'x'. size_t is for sizes, and div_t and ldiv_t are the structures returned by div and ldiv.

Please log in or register to report this question.

77.

Which of the following macros is not defined?

Answer: A

Correct answer: ULONG_MIN

There is no ULONG_MIN, and there could be no use for one: the minimum of an unsigned type is always 0, so the standard defines only the maxima for unsigned types. Signed types get both, hence LONG_MIN and LONG_MAX.

Please log in or register to report this question.

78.

Which of the given options is an array type used for holding information?

Answer: C

Correct answer: jmp_buf

jmp_buf is an array type declared in <setjmp.h>, holding the calling environment - registers, stack pointer, program counter - saved by setjmp. Being an array is what lets it be passed to longjmp without an explicit &.

Please log in or register to report this question.

79.

A non-zero value is returned, if setjmp() returns from a longjmp() function call.

Answer: B

Correct answer: true

setjmp returns 0 when it is called directly to save the environment, and a non-zero value when control arrives there from a longjmp - the value longjmp was given. Testing the return value is how the code distinguishes the two arrivals.

Please log in or register to report this question.

Answer: A

Correct answer: The abs() function is similar to the labs() function, except that the argument and the returned value each of them have type long int

The two do the same thing for different types: abs takes and returns an int, and labs takes and returns a long int. (llabs was added for long long, and fabs handles floating point.)

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Library Functions Questions and Answers || Library Functions MCQ Questions and Answers || Library Functions GK Questions and Answers || Library Functions GK MCQ Questions || Library Functions Multiple Choice Questions and Answers || Library Functions GK || GK on Library Functions || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming