C Programming String Multiple choice question

Exercise : - Multiple Choice Question On C Programming, MCQ C Programming String

This section contains a lot of c programming question and answer with explanation on the topic string. These question and answer are very much helpful for interview(campus interviews, walkin interviews, company interviews), competitive examination ,entrance test and placements. Each question having answer and explanation that would help you to understand easily. These question are designed from basic to advance level. So anyone can learn from here (beginner, fresher, engineering graduate, an experienced IT professional).

All the question of c programming are listed below on string along with detailed explanation / solution and answer.

1) A string is nothing but an array of characters terminated by '\0'.
A. False
B. True

Answer:

True

Option:

( B )


Explanation :

No explanations available for this question.


2) If the two strings are identical, then strcmp() function returns
A. -1
B. 1
C. Zero (0)
D. Yes

Answer:

Zero (0)

Option:

( C )


Explanation :

The strcmp return an int value that is if s1 < s2 returns a value < 0 if s1 == s2 returns 0 if s1 > s2 returns a value > 0


3) Which of the following function is used to find the first occurrence of a given string in another string?
A. strchr()
B. strrchr()
C. strnset()
D. strstr()

Answer:

strstr()

Option:

( D )


Explanation :

The function strstr() Finds the first occurrence of a substring in another string


4) The library function used to find the last occurrence of a character in a string is
A. strrchr()
B. strnstr()
C. strstr()
D. None of the Above

Answer:

strrchr()

Option:

( A )


Explanation :

Declaration: char *strrchr(const char *s, int c); It scans a string s in the reverse direction, looking for a specific character c.


5) Which is more appropriate for reading in a multi-word string? gets( ),printf( ),scanf( ),puts( )
A. printf( )
B. scanf( )
C. gets( )
D. None of the Above

Answer:

gets( )

Option:

( C )


Explanation :

No explanations available for this question.