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

Library Functions Questions and Answers

71.

The mbstowcs() function is used to return the number of array elements modified, not including a terminating zero code, if any.

Answer: A

Correct answer: true

mbstowcs() converts a multibyte string to a wide-character string and returns the number of wide characters written, not counting the terminating null - or (size_t)-1 if it meets an invalid multibyte sequence.

Please log in or register to report this question.

72.

Input/output function prototypes and macros are defined in which header file?

Answer: C

stdio.h, which stands for "standard input/output header", is the header in the C standard library that contains macro definitions, constants, and declarations of functions and types used for various standard input and output operations.

Please log in or register to report this question.

73.

Which function is used to recombine the fraction and exponent parts of a floating-point value after you have worked on them separately?

Answer: D

Correct answer: ldexp()

ldexp(x, n) computes \(x \times 2^{n}\) - it puts a fraction and an exponent back together. It is the inverse of frexp, which splits a value into those two parts. modf splits into integral and fractional parts, a different decomposition.

Please log in or register to report this question.

Answer: A

Correct answer: Maximum number of bytes in a multi-byte character

MB_LEN_MAX, in <limits.h>, is the largest number of bytes any multibyte character can occupy in any supported locale - so a buffer of that size is always big enough. Its companion MB_CUR_MAX, in <stdlib.h>, gives the maximum for the locale currently in force.

Please log in or register to report this question.

75.

Which macro is used in the setlocale() function?

Answer: C

Correct answer: LC_MESSAGES

The category macros passed to setlocale are LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME and, in POSIX, LC_MESSAGES. Each names one aspect of the locale, so that a program can, say, take its number formatting from one locale and its messages from another.

Please log in or register to report this question.

Answer: A

Correct answer: void longjmp(jmp_buf environment, int value)

longjmp takes the jmp_buf saved by setjmp and an int, and restores the saved environment - whereupon setjmp appears to return that value. A value of 0 is silently changed to 1, so that the caller can always distinguish a longjmp arrival from the original call.

Please log in or register to report this question.

77.

Which of the given option is declared under the header file stdlib.h?

Answer: D

Correct answer: EXIT_SUCCESS

EXIT_SUCCESS and EXIT_FAILURE are defined in <stdlib.h>, alongside NULL, RAND_MAX and MB_CUR_MAX. SEEK_CUR and SEEK_END belong to <stdio.h> and CLOCKS_PER_SEC to <time.h>.

Please log in or register to report this question.

78.

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.

79.

What will be the output of the program?

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char *i = "55.555";
    int result1 = 10;
    float result2 = 11.111;
    result1 = result1+atoi(i);
    result2 = result2+atof(i);
    printf("%d, %f", result1, result2);
    return 0;
}

 

Answer: C

Function atoi() converts the string to integer.
Function atof() converts the string to float.

result1 = result1+atoi(i);
Here result1 = 10 + atoi(55.555);
result1 = 10 + 55;
result1 = 65;

result2 = result2+atof(i);
Here result2 = 11.111 + atof(55.555);
result2 = 11.111 + 55.555000;
result2 = 66.666000;
So the output is "65, 66.666000" .

Please log in or register to report this question.

80.

The _______ macro shall be invoked before any access to the unnamed arguments.

Answer: D

Correct answer: va_start

va_start must be called first: it initialises the va_list, using the last named parameter to work out where the unnamed ones begin. Only then may va_arg fetch them, and va_end must be called before the function returns.

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