C Arrays and Strings-2
1. 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: A
The prototype of strcoll() function is int strcoll(const char *s1,const char *s2).
2. What is the function of strcoll()?
a) copies the string, result is dependent on the LC_COLLATE
b) compares the string, result is not dependent on the LC_COLLATE
c) compares the string, result is dependent on the LC_COLLATE
d) copies the string, result is not dependent on the LC_COLLATE
Answer: C
The strcoll() function compares the string s1 to the string s2, both interpreted as appropriate to the LC_COLLATE category of the current locale.
3. Which of the following is the variable type defined in header string.h?
a) sizet
b) size
c) size_t
d) size-t
Answer: C
This is the unsigned integral type and is the result of the sizeof keyword.
4. NULL is the macro defined in the header string. h?
a) True
b) False
Answer: A
NULL macro is the value of a null pointer constant.
5. What is the maximum length of a C String?
a) 32 characters
b) 64 characters
c) 256 characters
d) None of the above
Answer: D
Maximum size of a C String is dependent on implemented PC memory. C does not restrict C array size or String Length.
6. How do you accept a Multi Word Input in C Language?
a) SCANF
b) GETS
c) GETC
d) FINDS
Answer: B
Yes, gets(str) fills the array str with the input given by the user.
7. Choose a correct C Statement about Strings.
a) PRINTF is capable of printing a multi word string
b) PUTS is capable of printing a multi word string
c) GETS is capable of accepting a multi word string from console or command prompt
d) All the above
Answer: D
No explaination is given for this question.
8. What will be the output of the following piece of code?
int main() {
char p[] = "GODZILLA";
int i = 0;
while(p[i] != '\0') {
printf("%c", *(p+i));
i++;
}
return 0;
}
a) G
b) GODZILLA
c) Compiler error
d) None of the above
Answer: B
Notice the usage of *(p+i). Remember that, p[i] == *(p+i) == *(i+p) == i[p]
9. What is the ASCII value of NULL or \0?
int main() {
char str[] = {'g', 'l', 'o', 'b', 'a', 'l'};
printf("%s", str);
return 0;
}
a) 12
b) 0
c) 56
d) None of these
Answer: B
ASCII value of NULL character is ZERO 0.
10. A character constant is enclosed by?
a) Left Single Quotes
b) Right Single Quotes
c) Double Quotes
d) None of the above
Answer: B
No explaination is given for this question.