1.

In C++ the size of the string “book” is 5 and that of “book\n” is 6. Check the validity of the above statement. Justify your answer.

Answer»

A string is automatically added by a null character(\0). The null character is treated as one character. So the size of string “book” is 5. Similarly, a null character (\0) is also added to “book\n”. \n and \0 is treated as single characters. Hence the size of the string “book\n” is 6.



Discussion

No Comment Found

Related InterviewSolutions