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

Library Functions Questions and Answers

61.

The _______ function sorts an array of objects.

Answer: D

Correct answer: qsort()

qsort() sorts an array in place, given the base address, the number of elements, the size of each, and a comparison function the caller supplies. Passing the comparison as a function pointer is what makes it work on any type at all. The other three names do not exist.

Please log in or register to report this question.

62.

What will be the output of the program?

#include <stdio.h>

int main()
{
    int i;
    i = scanf("%d %d", &i, &i);
    printf("%d\n", i);
    return 0;
}

 

Answer: B

Correct answer: 2

scanf returns the number of items successfully converted and assigned, not the values themselves. Two conversions succeed here, so it returns 2, and that is what is stored in i and printed - overwriting whatever the two conversions had put there.

Please log in or register to report this question.

63.

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.

65.

What will be the output of the program?

#include <stdio.h>

int main()
{
    int i;
    i = printf("How r u\n");
    i = printf("%d\n", i);
    printf("%d\n", i);
    return 0;
}

 

Answer: B

In the program, printf() returns the number of charecters printed on the console

i = printf("How r u\n"); This line prints "How r u" with a new line character and returns the length of string printed then assign it to variable i.
So i = 8 (length of '\n' is 1).

i = printf("%d\n", i); In the previous step the value of i is 8. So it prints "8" with a new line character and returns the length of string printed then assign it to variable i. So i = 2 (length of '\n' is 1).

printf("%d\n", i); In the previous step the value of i is 2. So it prints "2".

Please log in or register to report this question.

66.

Which of the given function differs from the statement'errno is not neccessarily set on conversion error'?

Answer: D

Correct answer: strtod()

strtod is the one that does report the error: on overflow or underflow it sets errno to ERANGE, and it also returns a pointer to the first character it could not convert. atof, atoi and atol simply return 0 on failure, which is indistinguishable from a legitimate 0 - which is why the strto family should be used in real code.

Please log in or register to report this question.

67.

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.

68.

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.

69.

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.

70.

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.

Loading…
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