Arrays And Strings - Study Mode

[#1] Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?
Correct Answer

(A) arr[6]

Explanation

Solution: Array index always starts with 0.

[#2] int a [ 5 ] = { 1,2,3 } What is the value of a [ 4 ] ?
Correct Answer

(D) 0

Explanation

Solution: In the fourth location of an array it contains 0 since default initialization will take place.

[#3] The C library function checks whether the passed character is printable.
Correct Answer

(C) isprint()

[#4] Which of the following is the variable type defined in header string. h?
Correct Answer

(C) size_t

[#5] Which among the given options is the right explanation for the statement size_t strcspn(c, s)?
Correct Answer

(C) return length of prefix of c consisting of characters not in s