C- Library Functions MCQ Questions and Answers

Practice Mode
Showing 10 of 29 questions
Q11
Which function is used to convert a string to uppercase in C?
  • A toupper()
  • B upper()
  • C strupr()
  • D strtoupper()
Answer: Option C
Explanation: strupr() function converts all lowercase letters in a string to uppercase.
Q12
What does the malloc() function do in C?
  • A Memory Allocation
  • B Memory Deallocation
  • C Memory Reallocation
  • D Memory Initialization
Answer: Option A
Explanation: malloc() allocates memory dynamically on the heap.
Q13
Which function is used to compare two strings in C?
  • A strcomp()
  • B strcompare()
  • C strcmp()
  • D compare()
Answer: Option C
Explanation: strcmp() compares two strings and returns 0 if they are equal.
Q14
Which header file contains mathematical functions like sqrt() and pow()?
  • A stdlib.h
  • B math.h
  • C string.h
  • D stdio.h
Answer: Option B
Explanation: math.h header contains mathematical functions.
Q15
What does the printf() function return?
  • A void
  • B int
  • C char
  • D float
Answer: Option B
Explanation: printf() returns the number of characters printed.
Q16
Which function is used to open a file in C?
  • A open()
  • B fopen()
  • C fileopen()
  • D openfile()
Answer: Option B
Explanation: fopen() is used to open files in C.
Q17
What does the strlen() function return?
  • A Number of characters including null
  • B Number of characters excluding null
  • C Size of string in bytes
  • D Pointer to last character
Answer: Option B
Explanation: strlen() returns the length of string excluding null character.
Q18
Which function is used to copy one string to another?
  • A strcopy()
  • B strcpy()
  • C copy()
  • D stringcopy()
Answer: Option B
Explanation: strcpy() copies source string to destination string.
Q19
What is the purpose of free() function?
  • A Allocate memory
  • B Deallocate memory
  • C Initialize memory
  • D Reallocate memory
Answer: Option B
Explanation: free() deallocates memory allocated by malloc/calloc.
Q20
Which function is used to read a character from file?
  • A getchar()
  • B fgetc()
  • C getc()
  • D readchar()
Answer: Option B
Explanation: fgetc() reads a character from file stream.
Questions and Answers for Competitive Exams Various Entrance Test