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.


In C++, what is the main function's return type?

  1. char

  2. void

  3. int

  4. float

The correct answer is: int

The main function's return type in C++ is generally an integer (int) type, denoted by the keyword "int". This is because the main function is used to execute the program and return a value to the operating system. In this case, the function returns an integer value which indicates whether the program ran successfully or encountered an error. Option A (char) is incorrect because a char type is used for storing single characters and is not ideal for representing a program's return value. Option D (float) is also incorrect because float is used for representing decimal numbers and would not be useful for a program's return value. Option B (void) is incorrect because void functions do not return a value, making it unsuitable for the main function which is expected to return a value to the operating system.