Explore topic-wise MCQs in Library Functions.

This section includes 88 Mcqs, each offering curated multiple-choice questions to sharpen your Library Functions knowledge and support exam preparation. Choose a topic below to get started.

51.

A preprocessor command

A. need not start on a new line
B. need not start on the first column
C. has # as the first character
D. comes before the first executable statement
Answer» D. comes before the first executable statement
52.

The source filename and line number come from the preprocessor macros________and______

A. _ _FILE_ _ and _ _LINE_ _
B. _ _NAME_ _ and _ _NUMBER_ _
C. _ _FILENAME_ _ and _ _NMN_ _
D. _ _FILE_ _ and _ _NUM_ _
Answer» B. _ _NAME_ _ and _ _NUMBER_ _
53.

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

A. true
B. false
Answer» B. false
54.

C preprocessor

A. Takes care of conditional compilation
B. Takes care of macros
C. Takes care of include files
D. All of the above
Answer» E.
55.

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

A. minutes
B. clock ticks
C. milli-seconds
D. micro-seconds
Answer» C. milli-seconds
56.

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

A. True
B. False
Answer» B. False
57.

Select the function that reads or sets location dependent information.

A. longjmp()
B. setlocale()
C. assert()
D. toupper()
Answer» C. assert()
58.

The pointer used in the mblen() function points to the _________

A. first byte of multibyte character
B. last byte of multibyte character
C. middle byte of multibyte character
D. no pointer is used in mblen function
Answer» B. last byte of multibyte character
59.

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

A. true
B. false
Answer» B. false
60.

MB_CUR_MAX is not defined in stdlib.h.

A. true
B. false
Answer» C.
61.

Which of the following is the correct code?

A. tanh(double x)
B. tanh double x
C. tanhdouble x
D. tanhdoublex
Answer» B. tanh double x
62.

The header file assert.h of the C Standard Library defines ________macro.

A. stderr
B. stdarg
C. setjmp
D. assert
Answer» E.
63.

The purpose of the function ctime() is that ___________

A. it returns a string representing the local time
B. it returns a void string
C. it returns a string representing the time in UTC format
D. it returns a string representing the time stored in a structure
Answer» B. it returns a void string
64.

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

A. strnct()
B. fabs()
C. iscntrl()
D. null
Answer» E.
65.

Determine Output:

 #include #define a 10 void main() { #define a 50 printf("%d", a); }

A. 50
B. 10
C. Compiler Error
D. None of These
Answer» B. 10
66.

Point out the error in the following program.

 #include int main() { char str[] = "IndiaBIX"; printf("%.#s %2s", str, str); return 0; }

A. Error: in Array declaration
B. Error: printf statement
C. Error: unspecified character in printf
D. No error
Answer» E.
67.

Point out the error in the following program.

 #include #include int main() { char str1[] = "Learn through Compscibits 0.com", str2[120]; char *p; p = (char*) memccpy(str2, str1, 'i', strlen(str1)); *p = ' 0'; printf("%s", str2); return 0; }

A. Error: in memccpy statement
B. Error: invalid pointer conversion
C. Error: invalid variable declaration
D. No error and prints "Learn through Comp"
Answer» E.
68.

What will be the output of the program?

 #include int main() { int i; char c; for(i=1; i<=5; i++) { scanf("%c", &c); /* given input is 'a' */ printf("%c", c); ungetc(c, stdin); } return 0; }

A. aaaa
B. aaaaa
C. Garbage value
D. Error in ungetc statement
Answer» C. Garbage value
69.

What will function gcvt() do?

A. Convert vector to integer value
B. Convert floating-point number to a string
C. Convert 2D array in to 1D array
D. Covert multi Dimensional array to 1D array
Answer» C. Convert 2D array in to 1D array
70.

What is the purpose of fflush() function ?

A. flushes all streams and specified streams
B. flushes only specified stream
C. flushes input/output buffer
D. flushes file buffer
Answer» B. flushes only specified stream
71.

What is stderr ?

A. standard error
B. standard error types
C. standard error streams
D. standard error definitions
Answer» D. standard error definitions
72.

Which standard library function will you use to find the last occurrence of a character in a string in C?

A. strnchar()
B. B.
C.
D. strrchar()
E. D.
Answer» E. D.
73.

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

A. Yes
B. No
Answer» B. No
74.

scanf() or atoi() function can be used to convert a string like "436" in to integer.

A. Yes
B. No
Answer» B. No
75.

The itoa function can convert an integer in decimal, octal or hexadecimal form to a string.

A. Yes
B. No
Answer» B. No
76.

Will the program outputs "IndiaBIX.com"?

 #include #include int main() { char str1[] = "IndiaBIX.com"; char str2[20]; strncpy(str2, str1, 8); printf("%s", str2); return 0; }

A. Yes
B. No
Answer» C.
77.

If the two strings are found to be unequal then strcmp returns difference between the first non-matching pair of characters.

A. True
B. False
Answer» B. False
78.

What will the function rewind() do?

A. Reposition the file pointer to a character reverse
B. Reposition the file pointer stream to end of file
C. Reposition the file pointer to beginning of that line
D. Reposition the file pointer to begining of file
Answer» E.
79.

Data written into a file using fwrite() can be read back using fscanf()

A. True
B. False
Answer» C.
80.

FILE is a structure suitably typedef'd in "stdio.h".

A. True
B. False
Answer» B. False
81.

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

A. True
B. False
Answer» B. False
82.

What will be the output of the program?

 #include #include int main() { char dest[] = {97, 97, 0}; char src[] = "aaa"; int i; if((i = memcmp(dest, src, 2))==0) printf("Got it"); else printf("Missed"); return 0; }

A. Missed
B. Got it
C. Error in memcmp statement
D. None of above
Answer» C. Error in memcmp statement
83.

What will be the output of the program?

 #include #include 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; }

A. 55, 55.555
B.
C. C.
D. D.
Answer» D. D.
84.

What will be the output of the program?

 #include int main() { int i; char c; for(i=1; i<=5; i++) { scanf("%c", &c); /* given input is 'b' */ ungetc(c, stdout); printf("%c", c); ungetc(c, stdin); } return 0; }

A. bbbb
B. bbbbb
C. b
D. Error in ungetc statement.
Answer» D. Error in ungetc statement.
85.

What will be the output of the program?

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

A. 1
B. 2
C.
D. D.
Answer» C.
86.

What will be the output of the program?

 #include #include<math.h> int main() { float i = 2.5; printf("%f, %d", floor(i), ceil(i)); return 0; }

A. 2, 3
B. 2.000000, 3
C. 2.000000, 0
D. 2, 0
Answer» D. 2, 0
87.

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

A. atof()
B. atoi()
C. atol()
D. strtod()
Answer» E.
88.

______ macro must be called before using ______ and ________

A. va_arg, va_end and va_start
B. va_start, va_end and va_arg
C. va_end, va_arg and va_start
D. v_arg, v_end and v_start
Answer» C. va_end, va_arg and va_start