Explore topic-wise MCQs in C.

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

1.

Which of the following is the variable type defined in header string. h?

A. sizet
B. size
C. size_t
D. size-t
Answer» D. size-t
2.

The ______ function appends not more than n characters.

A. strcat()
B. strcon()
C. strncat()
D. memcat()
Answer» D. memcat()
3.

Which among the following is Copying function?

A. memcpy()
B. strcopy()
C. memcopy()
D. strxcpy()
Answer» B. strcopy()
4.

Strcat() function adds null character.

A. Only if there is space
B. Always
C. Depends on the standard
D. Depends on the compiler
Answer» C. Depends on the standard
5.

What will the given C code do?

A. compares the first n bytes of str1 and str2
B. copies the first n bytes of str1 to str2
C. copies the first n bytes of str2 to str1
D. invalid functionView Answer
Answer» B. copies the first n bytes of str1 to str2
6.

void *memcpy(void *dest, const void *src, size_t n) What does the following code do?

A. copies n characters from src to dest
B. copies n character from dest to src
C. transform n character from dest to src
D. transform n character from src to dest
Answer» B. copies n character from dest to src
7.

Use_______to determine the null-terminated message string that corresponds to the error code errcode.

A. strerror()
B. strstr()
C. strxfrm()
D. memset()
Answer» B. strstr()
8.

What will the following C code do?

A. find last occurrence of c in char s[ ].
B. find first occurrence of c in char s[ ].
C. find the current location of c in char s[ ].
D. There is error in the given codeView Answer
Answer» B. find first occurrence of c in char s[ ].
9.

What will be returned in the following C code?

A. number of characters equal in sc
B. length of string s
C. doesn’t return any value
D. displays string sView Answer
Answer» C. doesn’t return any value
10.

The______ function returns the number of characters that are present before the terminating null character.

A. strlength()
B. strlen()
C. strlent()
D. strchr()
Answer» C. strlent()
11.

The C library function _________ breaks string s1 into a series of tokens using the delimiter s2.

A. char *strtok(char *s1,const char *s2);
B. char *strtok(char *s2,const char *s1);
C. char *strstr(char *s1,const char *s2);
D. char *strstr(char *s2,const char *s1);
Answer» B. char *strtok(char *s2,const char *s1);
12.

What is the return value of strxfrm()?

A. length of the transformed string, not including the terminating null-character
B. length of the transformed string, including the terminating null-character
C. display the transformed string, not including the terminating null character
D. display the transformed string, not including the terminating null-character
Answer» B. length of the transformed string, including the terminating null-character
13.

BEFORE_MEMMOVE_PLACE=_STRING1,_SRC_=_STRING2_AFTER_MEMMOVE_PLACE_=_STRING2,_SRC_=_STRING2?$

A. Before memmove place = string2, src = string2 After memmove place= string1, src = string2
B. Before memmove place = string2, src = string1 After memmove place= string2, src =string2
C. Before memmove place= string1, src = string2 After memmove place=string1, src = string1
Answer» B. Before memmove place = string2, src = string1 After memmove place= string2, src =string2
14.

STORE_C_THROUGHOUT_UNSIGNED_CHAR_S[N]?$

A. store c throughout signed char s[n]
B. find first occurrence of c in s[n]
C. find last occurrence of c in s[n]
Answer» B. find first occurrence of c in s[n]
15.

NULL is the macro defined in the header string. h.

A. true
B. false
Answer» B. false
16.

str1 is not greater than str2

A. str2 is not greater than str1
B. both are equal
C. error in given code
Answer» B. both are equal
17.

The strpbrk() function is used to return a pointer to the character, or a null pointer if no character from s2 occurs in s1.

A. true
B. false
Answer» B. false
18.

Which of the following is the variable type defined in header string. h

A. sizet
B. size
C. size_t
D. size-t
Answer» D. size-t
19.

Which of the given function is used to return a pointer to the located character?

A. strrchr()
B. strxfrm()
C. memchar()
D. strchar()
Answer» E.
20.

What is the function of strcoll()?

A. compares the string, result is dependent on the LC_COLLATE
B. copies the string, result is dependent on the LC_COLLATE
C. compares the string, result is not dependent on the LC_COLLATE
D. copies the string, result is not dependent on the LC_COLLATE
Answer» B. copies the string, result is dependent on the LC_COLLATE
21.

This function offers the quickest way to determine whether two character sequences of the same known length match character for the character up to and including any null character in both.

A. strcmp()
B. memcmp()
C. strncmp()
D. no such function
Answer» B. memcmp()
22.

which of the following function returns a pointer to the located string or a null pointer if string is not found.

A. strtok()
B. strstr()
C. strspn()
D. strrchr()
Answer» C. strspn()
23.

What is the prototype of strcoll() function?

A. int strcoll(const char *s1,const char *s2)
B. int strcoll(const char *s1)
C. int strcoll(const *s1,const *s2)
D. int strcoll(const *s1)
Answer» B. int strcoll(const char *s1)
24.

hello, world 11

A. hello, wor 9
B. Undefined behaviour
C. Compilation error
Answer» B. Undefined behaviour
25.

The______function returns a pointer to the first character of a token.

A. strstr()
B. strcpy()
C. strspn()
D. strtok()
Answer» E.
26.

What will strcmp() function do?

A. compares the first n characters of the object
B. compares the string
C. undefined function
D. copies the string
Answer» C. undefined function
27.

The C library function_________ breaks string s1 into a series of tokens using the delimiter s2.

A. char *strtok(char *s1,const char *s2);
B. char *strtok(char *s2,const char *s1);
C. char *strstr(char *s1,const char *s2);
D. char *strstr(char *s2,const char *s1);
Answer» B. char *strtok(char *s2,const char *s1);
28.

The ______function appends not more than n characters.

A. strcat()
B. strcon()
C. strncat()
D. memcat()
Answer» D. memcat()
29.

Compilation error

A. Segmentation Fault
B. hello, world
C. hello, wo 9
Answer» D.
30.

The function strsp() is the complement of strcspn().

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

Is there any function declared as strstr()?

A. true
B. false
Answer» B. false
32.

Which function will you choose to join two words?

A. strcpy()
B. strcat()
C. strncon()
D. memcon()
Answer» C. strncon()
33.

number of characters equal in sc

A. length of string s
B. doesn’t return any value
C. displays string s
Answer» B. doesn‚Äö√Ñ√∂‚àö√ë‚àö¬•t return any value