The C-string cityName[30] can contain ________.
A) thirty characters
B) thirty one characters
C) twenty nine characters and the null terminator
D) thirty characters and the null terminator
E) None of the above
In C,
defining string as cityName[30] means it will have string of 30 characters. Also all string is terminated by a NULL string. So that is not something is mentioned but is understood by default.
The number of characters in character array is defined in the square bracket [ ] . The first character will be placed at index 0.
So the correct option is (D).
No space is given to null Terminator while defining size of character array. It is just appended at the last position of array.
If you have any questions comment down and please? upvote thanks
Get Answers For Free
Most questions answered within 1 hours.