adplus-dvertising
1. Which of the following function sets first n characters of a string to a given character?
a. strinit()
b. strnset()
c. strset()
d. strcset()
Discuss
Answer: (b).strnset()

2. If the two strings are identical, then strcmp() function returns
a. -1
b. 1
c. 0
d. Yes
Discuss
Answer: (c).0

3. How will you print \n on the screen?
a. printf("\n");
b. echo "\\n";
c. printf('\n');
d. printf("\\n");
Discuss
Answer: (d).printf("\\n");

4. The library function used to find the last occurrence of a character in a string is
a. strnstr()
b. laststr()
c. strrchr()
d. strstr()
Discuss
Answer: (c).strrchr()

5. Which of the following function is used to find the first occurrence of a given string in another string?
a. strchr()
b. strrchr()
c. strstr()
d. strnset()
Discuss
Answer: (c).strstr()

6. Which of the following function is more appropriate for reading in a multi-word string?
a. printf();
b. scanf();
c. gets();
d. puts();
Discuss
Answer: (c).gets();

7. Strcat function adds null character
a. Only if there is space
b. Always
c. Depends on the standard
d. Depends on the compiler
Discuss
Answer: (b).Always

8. The return-type used in String operations are
a. void only
b. void and (char *) only
c. void and int only
d. void, int and (char *) only
Discuss
Answer: (d).void, int and (char *) only

9. String operation such as strcat(s, t), strcmp(s, t), strcpy(s, t) and strlen(s) heavily rely upon.
a. Presence of NULL character
b. Presence of new-line character
c. Presence of any escape sequence
d. None of the mentioned
Discuss
Answer: (a).Presence of NULL character

10. Which pre-defined function returns a pointer to the last occurence of a character in a string?
a. strchr(s, c);
b. strrchr(s, c);
c. strlchr(s, c);
d. strfchr(s, c);
Discuss
Answer: (b).strrchr(s, c);

Page 1 of 2