Array & String MCQ

11. Length of the string "letsfindcourse" is

A. 13
B. 14
C. 15
D. 12

View Answer


12.How will you print \n on the screen?

A. printf("\n");
B. printf('\n');
C. printf("\\n");
D. printf("\"\n"")

View Answer


13. If the two strings are identical, then strcmp() function returns

A. -1
B. 1
C. 0
D. None

View Answer


14. Which of the following statements are correct ?
    1: A string is a collection of characters terminated by ''.
    2: The format specifier %s is used to print a string.
    3: The length of the string can be obtained by strlen().
    4: The pointer CANNOT work on string.

A. 1,2,3
B. 1,2
C. 2,4
D. 3,4

View Answer


15.Let x be an array.Which of the following operations is illegal?
i) ++x.
ii) x+1.
iii) x++.
iv) x*2.

A. I and II
B. I, II and III
C. II and III
D. I, III and IV
E. III and IV

View Answer


16. Strcat function adds null character

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

View Answer


17. Which of the following function sets first n characters of a string to a given character?

A. strset()
B. strnset()
C. strcset()
D. strinit()

View Answer


18. 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


19. Which of the following gives the memory address of the first element in array foo, an array with 10 elements?

A. foo
B. &foo
C. foo[0]
D. &foo[0]

View Answer


20. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?

A. The element will be set to 0.
B. The compiler would report an error.
C. The program may crash
D. None of the above

View Answer







Also check :


Discussion


* You must be logged in to add comment.