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() |
View Answer Report Discuss Too Difficult! Search Google |
Answer: (b).strnset()
|
2. | If the two strings are identical, then strcmp() function returns |
a. | -1 |
b. | 1 |
c. | 0 |
d. | Yes |
View Answer Report Discuss Too Difficult! Search Google |
Answer: (c).0
|
3. | How will you print \n on the screen? |
a. | printf("\n"); |
b. | echo "\\n"; |
c. | printf('\n'); |
d. | printf("\\n"); |
View Answer Report Discuss Too Difficult! Search Google |
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() |
View Answer Report Discuss Too Difficult! Search Google |
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() |
View Answer Report Discuss Too Difficult! Search Google |
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(); |
View Answer Report Discuss Too Difficult! Search Google |
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 |
View Answer Report Discuss Too Difficult! Search Google |
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 |
View Answer Report Discuss Too Difficult! Search Google |
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 |
View Answer Report Discuss Too Difficult! Search Google |
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); |
View Answer Report Discuss Too Difficult! Search Google |
Answer: (b).strrchr(s, c);
|