Explore topic-wise MCQs in C.

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

1.

The system() function passes the string pointed to by string to the host environment to be executed by a command processor in an implementation-defined manner.

A. true
B. falseView Answer
Answer» B. falseView Answer
2.

Which among the given function causes abnormal program termination ?

A. exit()
B. abort()
C. atexit()
D. getenv()
Answer» C. atexit()
3.

void free(void *ptr) deallocates the memory previously allocated by a call to _______ ________ or _________

A. malloc,getenv,abort
B. calloc,malloc,exit
C. calloc,malloc,realloc
D. exit,getenv,abort
Answer» D. exit,getenv,abort
4.

Select the multibyte character function defined under the header file stdlib.h.

A. wctomb()
B. mblen()
C. mbtowc()
D. all of the mentioned
Answer» E.
5.

Which function returns a pseudo-random integer?

A. srand()
B. rand()
C. malloc()
D. alloc()
Answer» C. malloc()
6.

Which among the given function does not return a value?

A. strtoul()
B. strtol()
C. rand()
D. srand()
Answer» E.
7.

Is this right explanation to the given code?

A. true
B. falseView Answer
Answer» B. falseView Answer
8.

The calloc() function allocates space for an array of n objects, each of whose size is defined by size. Space is initialized to all bits zero.

A. true
B. false
Answer» B. false
9.

Which statement is correct work reference to endptr?

A. A pointer to the starting string is stored in the object pointed to by endptr, provided that endptr is a null pointer
B. A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is not a null pointer
C. A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is a null pointer
D. A pointer to the starting string is stored in the object pointed to by endptr, provided that endptr is not a null pointerView Answer
Answer» C. A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is a null pointer
10.

000000?$

A. String value = Hello, Float value = 0
B. String value = “Hello” , Float value = 0.000000
C. String value = “Hello” , Float value = 0
Answer» D.
11.

SELECT_THE_MULTIBYTE_CHARACTER_FUNCTION_DEFINED_UNDER_THE_HEADER_FILE_STDLIB.H.?$

A. wctomb()
B. mblen()
C. mbtowc()
D. all of the mentioned
Answer» E.
12.

Which of the given structure is returned by the function ldiv()?

A. div_t
B. ldiv_t
C. div_i
D. ldiv_i
Answer» C. div_i
13.

Which function searches an environmenr list that are provided by the host environment?

A. getenv()
B. system()
C. srand()
D. rand()
Answer» B. system()
14.

Select the right statement with reference to malloc() and calloc().

A. malloc() does not set the memory to zero whereas calloc() sets allocated memory to zero
B. malloc() sets the memory to zero whereas calloc() does not set allocated memory to zero
C. malloc() sets the memory to zero whereas calloc() sets allocated memory to zero
D. malloc() does not set the memory to zero whereas calloc() does not set allocated memory to zero
Answer» B. malloc() sets the memory to zero whereas calloc() does not set allocated memory to zero
15.

What members do the structure returned by function div() contains?

A. int quot and int rem
B. float quot and float rem
C. double quot and double rem
D. no members are returned by div()
Answer» B. float quot and float rem
16.

The behavior is undefined if more than one call to the exit function is executed by a program.

A. true
B. false
Answer» B. false
17.

Which of the following is the correct syntax of the function strtoul()?

A. unsigned long int strtoul(const char *n, char **ptr, int base)
B. unsigned long int strtoul(const char *n, char **ptr)
C. unsigned long int strtoul(const char *n)
D. int strtoul(const char *n)
Answer» B. unsigned long int strtoul(const char *n, char **ptr)
18.

Which function will return the quotient and remainder on division of numerator with denominator?

A. div()
B. div_t()
C. ldiv_t()
D. labs()
Answer» B. div_t()
19.

atol(const char *str) Converts the string pointed to, by the argument str.

A. to a long integer
B. to a integer
C. to a floating point number
D. to a unsigned long integer
Answer» B. to a integer
20.

Which of the given statement is true with respect to the function atexit()?

A. The atexit() function cannot return to its caller
B. The atexit() function is used to return zero if the registration succeeds, nonzero if it fails
C. The atexit() function returns no value
D. The atexit() function causes abnormal program termination to occur
Answer» C. The atexit() function returns no value
21.

The______function is used to convert the initial portion of the string pointed to by, to unsigned long int representation.

A. strtod()
B. atol()
C. strtoul()
D. strtol()
Answer» B. atol()
22.

The abs() function computes the absolute value __________

A. a floating number
B. an integer number
C. a double number
D. all of the mentioned
Answer» C. a double number
23.

The_______function converts the initial portion of the string pointed to by, to int representation.

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

Which among the given function causes abnormal program termination ?

A. exit()
B. abort()
C. atexit()
D. getenv()
Answer» C. atexit()
25.

Which of the following functions decomposes the input string into three pans: an initial, possibly empty, sequence of white-space characters?

A. strtod()
B. atof()
C. atol()
D. strtol()
Answer» B. atof()
26.

Which statement is true regarding abs() and labs()?

A. The abs() function is similar to the labs() function, except that the argument and the returned value each of them have type long int
B. The abs() function is not similar to the labs() function, except that the argument and the returned value in both functions have type long int
C. The abs() function is similar to the labs() function, except that the argument and the returned value each have type short int
D. The abs() function is not similar to the labs() function, except that the argument and the returned value in both function have type short int
Answer» B. The abs() function is not similar to the labs() function, except that the argument and the returned value in both functions have type long int
27.

Which of the given function converts the string pointed to, by the argument str to a floating-point number?

A. atof(const char *str)
B. strtod(const char *str, char **endptr)
C. atoi(const char *str)
D. atol(const char *str)
Answer» B. strtod(const char *str, char **endptr)
28.

What is the function of the void *realloc(void *str, size-t size);?

A. allocates space for an array of str objects, each of whose size is size
B. allocates space for an object whose size is specified by size and whose value is indeterminate
C. changes the size of the object pointed to by str to the size specified by size
D. causes the space pointed to by str to be deallocated, that is, made available for further allocation
Answer» D. causes the space pointed to by str to be deallocated, that is, made available for further allocation
29.

A pointer to the starting string is stored in the object pointed to by endptr, provided that endptr is a null pointer

A. A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is not a null pointer
B. A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is a null pointer
C. A pointer to the starting string is stored in the object pointed to by endptr, provided that endptr is not a null pointer
Answer» D.
30.

RAND_MAX macro is the maximum value returned by the rand function.

A. true
B. false
Answer» B. false
31.

What is returned by the function if the space cannot be allocated by the function malloc(), realloc() and calloc()?

A. value
B. error
C. null pointer
D. no value
Answer» D. no value
32.

The _______ function sorts an array of objects.

A. bsort()
B. hsort()
C. ssort()
D. qsort()
Answer» E.
33.

The ________ function returns no value.

A. malloc()
B. realloc()
C. free()
D. calloc()
Answer» D. calloc()
34.

234555 String is |WELCOME|

A. The number is 1.2345550 String is |WELCOME|
B. The number is 1.234555 String is |1.234555 WELCOME|
C. Errror
Answer» C. Errror
35.

Which of the following is the correct description of EXIT_FAILURE?

A. This is the value for the exit function to return in case of failure
B. This is the value for the exit function to terminate the program
C. This is the value for the exit function to return in case of success
D. This is the value for the exit function to return in case it is the maximum value
Answer» B. This is the value for the exit function to terminate the program
36.

Which function is called repeatedly by bsearch() to compare search elements against the elements in the array?

A. mblem()
B. wctomb()
C. compar()
D. labs()
Answer» D. labs()
37.

_______variable type defined in the header stdlib.h is an integer type of the size of a wide character constant.

A. size_t
B. wchar_t
C. div_t
D. ldiv_t
Answer» C. div_t
38.

Which of the given function is used for searching?

A. lsearch()
B. bsearch()
C. csearch()
D. qsearch()
Answer» C. csearch()