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

Library Functions Questions and Answers

1.

Match the List-I with List II and select the correct answer using the codes given below :

List I 'C' FunctionList II Include File
(a) a cos (d)(i) time.h
(b) abs (i)(ii) stdio.h
(c) fprint (f, ..........)(iii) math.h
(d) time (p)(iv) stdlib.h

Exam Year(s)

MH SET - 2018, SET Exam - 2018,

Answer: B

The correct matching is a-iii, b-iv, c-ii, d-i.

  • acos(d), the inverse cosine, is declared in math.h (iii).
  • abs(i), the integer absolute value, is declared in stdlib.h (iv).
  • fprintf(f, ...), printed as fprint, writes formatted output to a file stream and is in stdio.h (ii).
  • time(p) is declared in time.h (i).

A common slip is to look for abs in math.h, which holds fabs for floating-point values; the integer abs lives in stdlib.h, which rules out the codes giving it math.h.

Please log in or register to report this question.

3.

The prototypes of all standard library string functions are declared in the file string.h.

Answer: A

string.h is the header in the C standard library for the C programming language which contains macro definitions, constants, and declarations of functions and types used not only for string handling but also various memory handling functions.

Please log in or register to report this question.

4.

The macros defined under the header file limits.h are not defined under any other header file.

Answer: B

Correct answer: True

The statement as phrased - that the limits.h macros appear nowhere else - is true: CHAR_BIT, INT_MAX and their relatives are defined only in <limits.h>, and the floating-point limits only in <float.h>. Names such as NULL and size_t are the ones that appear in several headers.

Please log in or register to report this question.

5.

Initial seed is ________ for the function srand(unsigned int seed).

Answer: A

Correct answer: 1

If srand is never called, rand behaves as though srand(1) had been - the initial seed is 1. That is why an unseeded program produces the same sequence every time it runs.

Please log in or register to report this question.

6.

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.

Answer: C

Correct answer: returns a random number generator with a random value based on time

randomize() seeds the random number generator from the system clock, so that a program produces a different sequence on each run. Without it, rand() starts from the same seed every time and repeats the same numbers - which is convenient for debugging and useless for a game.

Please log in or register to report this question.

8.

Which library function converts a string to a double-precision floating point value ?

Answer: C

Correct answer: atof()

atof() parses a string into a double, atoi() into an int and atol() into a long. strtok() is unrelated, splitting a string into tokens on a set of delimiters.

Please log in or register to report this question.

9.

ftell() returns the current position of the pointer in a file stream.

Answer: A

Correct answer: True

ftell(fp) returns the current position as a long - the byte offset from the start for a binary file. Its usual companion is fseek: save a position with ftell, read on, and return to it later.

Please log in or register to report this question.

10.

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.

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