Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++'

Disable ads (and more) with a membership for a one time $2.99 payment

Test your C++ skills with our quiz based on Bruce Eckel's 'Thinking in C++'. Dive into object-oriented programming, advanced topics, and fundamentals. Perfect for learners and experts alike. Assess your knowledge and become a C++ master!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What is returned by 'oneChar()' if the function is called repeatedly until the end of the string and then called once more?

  1. The function restarts from the beginning of the string

  2. A random character

  3. The function returns 0

  4. The last character of the string is returned again

The correct answer is: The function returns 0

If the function is called repeatedly until the end of the string and then called once more, it will continue to return 0. This is because the function is only designed to return the first character of the string, and once it reaches the end, it will not be able to return any more characters and will just continue to return 0. Option A is incorrect because the function does not have the ability to restart from the beginning of the string. Option B is also incorrect because the function is not designed to return a random character. Lastly, option D is incorrect because the function will not continue to return the last character of the string after it has reached the end.