C- Library Functions MCQ Questions and Answers

Practice Mode
Showing 10 of 29 questions
Q21
What does calloc() initialize the allocated memory to?
  • A Garbage value
  • B Zero
  • C One
  • D NULL
Answer: Option B
Explanation: calloc() initializes allocated memory to zero.
Q22
Which function is used to write formatted output to string?
  • A printf()
  • B fprintf()
  • C sprintf()
  • D format()
Answer: Option C
Explanation: sprintf() writes formatted output to a string.
Q23
What is the return type of sizeof operator?
  • A int
  • B unsigned int
  • C size_t
  • D long int
Answer: Option C
Explanation: sizeof returns size_t which is unsigned integer type.
Q24
Which function searches for a character in a string?
  • A strstr()
  • B strchr()
  • C strfind()
  • D search()
Answer: Option B
Explanation: strchr() searches for first occurrence of character in string.
Q25
What does realloc() function do?
  • A Allocate new memory
  • B Deallocate memory
  • C Change size of allocated memory
  • D Initialize memory
Answer: Option C
Explanation: realloc() changes size of previously allocated memory block.
Q26
Which function is used to close a file in C?
  • A close()
  • B fclose()
  • C fileclose()
  • D endfile()
Answer: Option B
Explanation: fclose() is used to close an opened file.
Q27
What does the floor() function return?
  • A Smallest integer >= argument
  • B Largest integer <= argument
  • C Rounded value
  • D Absolute value
Answer: Option B
Explanation: floor() returns largest integer less than or equal to argument.
Q28
Which function is used to concatenate two strings?
  • A strconcat()
  • B concat()
  • C strcat()
  • D strjoin()
Answer: Option C
Explanation: strcat() appends source string to destination string.
Q29
What is the purpose of fflush() function?
  • A Clear input buffer
  • B Flush output buffer
  • C Fill buffer
  • D Delete buffer
Answer: Option B
Explanation: fflush() flushes the output buffer of a stream.
Questions and Answers for Competitive Exams Various Entrance Test