LearnFrenzy
Sign in Take a free test

C Library Functions · Exercise 1 of 4

C Library Functions Library Functions MCQ

  • 12 questions
  • Page 1 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Twelve multiple-choice questions on header files, math, string, stdlib, ctype and time functions and their return values. Pick an option to check your answer instantly.

Question 1 Easy

Which header must be included to use sqrt()?

A <stdlib.h>
B <math.h>
C <stdio.h>
D <cmath.h>
Question page & discussion
Question 2 Easy

In which header are qsort() and bsearch() declared?

A <search.h>
B <stdlib.h>
C <string.h>
D <sort.h>
Question page & discussion
Question 3 Easy

What does #include <string.h> actually bring into your program?

A The compiled code of every string function
B Declarations (prototypes, types, macros); the code itself is linked from the C library
C Nothing – it is only documentation
D A copy of the library's source code
Question page & discussion
Question 4 Easy

Which statement about main() is true?

A It is defined in &lt;stdio.h&gt;
B It is written by the programmer and called by the runtime startup code; it is not a library function
C It is a keyword
D It is optional in every C program
Question page & discussion
Question 5 Easy

What does strcmp(s1, s2) return when s1 comes before s2?

A -1 exactly
B A negative value (any negative int)
C 0
D false
Question page & discussion
Question 6 Easy

What is strlen("hello")?

A 6
B 5
C 4
D It depends on the array size
Question page & discussion
Question 7 Medium

Source and destination overlap. Which function copies the bytes correctly?

A memcpy
B memmove
C strcpy
D memset
Question page & discussion
Question 8 Easy

What is the purpose of srand(time(NULL));?

A It returns a random number
B It seeds the rand() generator so that each run produces a different sequence
C It makes rand() cryptographically secure
D It must be called before every rand()
Question page & discussion
Question 9 Easy

What is the difference between abs() and fabs()?

A No difference
B abs takes an int (stdlib.h); fabs takes a double (math.h)
C fabs is faster
D abs works only on positive numbers
Question page & discussion
Question 10 Medium

Which statement about strtok() is true?

A It never changes the input
B It writes '\0' over delimiters in the input and keeps internal state between calls, so it cannot be used on string literals
C It returns a newly allocated copy of each token
D It returns empty tokens between adjacent delimiters
Question page & discussion

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links