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

Library Functions Questions and Answers

101.

Is standard library a part of C language?

Answer: B

The C standard library consists of a set of sections of the ISO C standard which describe a collection of header files and library routines used to implement common operations, such as input/output and string handling, in the C programming language. The C standard library is an interface standard described by a document; it is not an actual library of software routines available for linkage to C programs.

Please log in or register to report this question.

Answer: D

Correct answer: Reposition the file pointer to the beginning of the file

rewind(fp) moves the file position indicator back to the beginning of the file and clears the error and end-of-file flags. It is equivalent to fseek(fp, 0L, SEEK_SET), except that it returns nothing and resets the flags.

Please log in or register to report this question.

Answer: A

Correct answer: first byte of multibyte character

mblen(s, n) examines the multibyte character beginning at s - the pointer must therefore be at its first byte, since the length can only be determined from there. It returns how many bytes that character occupies, so that a program can step through a multibyte string.

Please log in or register to report this question.

104.

What will be the output of the following C code?

int main () 
{ 
   printf("starting of program\n"); 
   printf("program exits\n"); 
   exit(0);  
   printf("program ends\n");  
   return(0); 
}

 

Answer: B

Correct answer: starting of program program exits

exit(0) terminates the program immediately, so the third printf and the return are never reached. Only the first two lines appear. Unlike return from main, exit can be called from anywhere and ends the whole program.

Please log in or register to report this question.

105.

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.

Answer: B

Correct answer: Convert floating-point number to a string

gcvt() converts a floating-point number to a string, in the shorter of fixed and exponential notation for the requested number of significant digits. It is a non-standard function of the old Unix and Turbo C libraries; sprintf is the portable way to do the same thing.

Please log in or register to report this question.

107.

Which of the following is defined under the header file time.h?

Answer: D

Correct answer: NULL

NULL is one of the few names defined in several headers at once, <time.h> among them - so a program gets it from whichever it happens to include. fabs belongs to <math.h>, iscntrl to <ctype.h> and the string functions to <string.h>.

Please log in or register to report this question.

Answer: C

Correct answer: specifies maximum value returned by rand()

RAND_MAX is the largest value rand() can return, guaranteed to be at least 32767. It is needed to scale the result - rand() / (RAND_MAX + 1.0) gives a fraction between 0 and 1. srand returns nothing at all.

Please log in or register to report this question.

109.

Which type has an alignment requirement at least as large as that of every other data type?

Answer: D

Correct answer: max_align_t

max_align_t is an object type whose alignment requirement is at least as strict as that of every other scalar type. It matters to allocators: memory returned by malloc must be suitably aligned for any type, which is exactly this alignment. size_t and ptrdiff_t are integer types, and NULL is not a type at all.

Please log in or register to report this question.

Answer: A

Correct answer: it returns a string representing the local time

ctime() takes a time_t and returns a printable string in local time, of the form Wed Jun 30 21:49:08 2021\n. It is asctime(localtime(t)) in one call. The string is in a static buffer, so it is overwritten by the next call.

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