C++ MCQ – Basic Objective Questions – Set 2

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Allcompiler
A
Allcompiler
Community Contributor
Quizzes Created: 4 | Total Attempts: 23,465
Questions: 10 | Attempts: 961

SettingsSettingsSettings
C++ MCQ  Basic Objective Questions  Set 2 - Quiz



Online MCQ Quiz on C++ Programming Language
This Quiz is for those users who want to test their command over the C++ Programming Language.


Questions and Answers
  • 1. 

    Identify the correct statement

    • A.

      Programmer can use comments to include short explanations within the source code itself.

    • B.

      All lines beginning with two slash signs are considered comments.

    • C.

      Comments very important effect on the behaviour of the program

    • D.

      All of Above

    Correct Answer
    A. Programmer can use comments to include short explanations within the source code itself.
    Explanation
    Programmers can use comments to include short explanations within the source code itself. This allows them to provide additional information or clarify certain sections of the code for themselves or other developers who may work on the code in the future. Comments are typically denoted by using two slash signs at the beginning of the line. They are not considered executable code and do not have any effect on the behavior of the program when it is run. Therefore, the correct statement is that programmers can use comments to include short explanations within the source code itself.

    Rate this question:

  • 2. 

    The directives for the preprocessors begin with

    • A.

      Ampersand symbol (&)

    • B.

      Two Slashes (//)

    • C.

      Number Sign (#)

    • D.

      Less than symbol (

    Correct Answer
    C. Number Sign (#)
    Explanation
    The correct answer is the number sign (#). Directives for preprocessors typically begin with the number sign symbol (#).

    Rate this question:

  • 3. 

    The file iostream includes

    • A.

      The declarations of the basic standard input-output library.

    • B.

      The streams of includes and outputs of program effect.

    • C.

      Both of these

    • D.

      None of these

    Correct Answer
    A. The declarations of the basic standard input-output library.
    Explanation
    The file iostream includes the declarations of the basic standard input-output library. This means that it contains the necessary functions and objects for performing input and output operations in a C++ program. These include functions like cout and cin, which are used for outputting and inputting data respectively. Including the iostream file allows the program to use these input-output functions and objects.

    Rate this question:

  • 4. 

    There is a unique function in C++ program by where all C++ programs start their execution

    • A.

      Start()

    • B.

      Begin()

    • C.

      Main()

    • D.

      Output()

    Correct Answer
    C. Main()
    Explanation
    In C++, the main() function is the unique function where all C++ programs start their execution. It serves as the entry point of the program, and any code written inside the main() function will be executed first. The main() function is required in every C++ program and is responsible for controlling the flow of the program by calling other functions and executing statements.

    Rate this question:

  • 5. 

    Every function in C++ are followed by

    • A.

      Parameters

    • B.

      Parenthesis

    • C.

      Curly braces

    • D.

      None of these

    Correct Answer
    B. Parenthesis
    Explanation
    In C++, every function is followed by parentheses. These parentheses are used to enclose the parameters that are passed to the function. The parameters are the values or variables that the function needs in order to perform its task. The parentheses are essential in order to correctly call and execute a function in C++. The other options, such as parameters or curly braces, are not always present after every function in C++.

    Rate this question:

  • 6. 

    Which of the following is false?

    • A.

      Cout represents the standard output stream in c++

    • B.

      Cout is declared in the iostream standard file

    • C.

      Cout is declared within the std namespace

    • D.

      None of above

    Correct Answer
    D. None of above
    Explanation
    The statement "None of above" is false because all of the previous statements are true. Cout represents the standard output stream in C++, it is declared in the iostream standard file, and it is declared within the std namespace.

    Rate this question:

  • 7. 

    Every statement in C++ program should end with

    • A.

      A full stop (.)

    • B.

      A Comma (,)

    • C.

      A Semicolon (;)

    • D.

      A colon (:)

    Correct Answer
    C. A Semicolon (;)
    Explanation
    In C++ programming, every statement should end with a semicolon (;). This is because the semicolon serves as a statement terminator, indicating the end of a particular line of code. It is essential to include the semicolon to ensure that the compiler can correctly interpret and execute the program. Omitting the semicolon can result in a syntax error and cause the program to fail during compilation. Therefore, the correct answer is a semicolon.

    Rate this question:

  • 8. 

    Which of the following statement is true about preprocessor directives?

    • A.

      These are lines read and processed by the preprocessor

    • B.

      They do not produce any code by themselves

    • C.

      These must be written on their own line

    • D.

      They end with a semicolon

    Correct Answer
    D. They end with a semicolon
    Explanation
    Preprocessor directives are lines of code that are read and processed by the preprocessor before the compilation of the program. They are not responsible for producing any code themselves, but rather modify the code before it is compiled. These directives must be written on their own line and they end with a semicolon. This is because the semicolon is used to terminate statements in most programming languages, and the preprocessor treats directives as statements that need to be terminated.

    Rate this question:

  • 9. 

    A block comment can be written by

    • A.

      Starting every line with double slashes (//)

    • B.

      Starting with /* and ending with */

    • C.

      Starting with //* and ending with *//

    • D.

      Starting with

    Correct Answer
    B. Starting with /* and ending with */
    Explanation
    A block comment can be written by starting with /* and ending with */. This is the correct way to write a block comment in many programming languages, including C, C++, and Java. The /* symbolizes the start of the comment block, and the */ symbolizes the end of the comment block. This allows multiple lines of code to be commented out at once, making it easier to add explanations or temporarily disable code.

    Rate this question:

  • 10. 

    When writing comments you can

    • A.

      Use code and /* comment on the same line

    • B.

      Use code and // comments on the same line

    • C.

      Use code and //* comments on the same line

    • D.

      Use code and

    Correct Answer
    B. Use code and // comments on the same line
    Explanation
    The correct answer is "Use code and // comments on the same line". This is because in most programming languages, including C++, Java, and Python, the double forward slash "//" is used to indicate a single-line comment. This allows you to add comments to your code without affecting its functionality. Using "//" comments on the same line as the code is a common practice and makes the code more readable and easier to understand for other developers.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 01, 2011
    Quiz Created by
    Allcompiler
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.