C++ MCQ - Basic Objective Questions - Set 1

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,166
Questions: 10 | Attempts: 4,022

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





Online MCQ Quiz on C++ Programming Language
No. Of Questions:- 10
Time:- 10 Minutes
Full Mark:- 100
Pass Mark:- 70

This Quiz is for those user who wants to test their command over the C++ Programming Language.


Questions and Answers
  • 1. 

    What is the correct value to return to the operating system upon the successful completion of a program?

    • A.

      -1

    • B.

      1

    • C.

      0

    • D.

      Programs do not return a value.

    Correct Answer
    C. 0
    Explanation
    Upon the successful completion of a program, it is standard practice to return the value 0 to the operating system. This value indicates that the program executed successfully without any errors or issues. Other values, such as -1 or 1, may be used to indicate specific error conditions or different types of successful completions, but the most common and generally accepted value to return is 0.

    Rate this question:

  • 2. 

    What is the only function all C++ programs must contain?

    • A.

      Start()

    • B.

      System()

    • C.

      Main()

    • D.

      Program()

    Correct Answer
    C. Main()
    Explanation
    The correct answer is "main()". In C++, the main() function is the entry point for all C++ programs. It is the function where the program starts its execution. Without the main() function, a C++ program cannot be executed.

    Rate this question:

  • 3. 

    What punctuation is used to signal the beginning and end of code blocks?

    • A.

      { }

    • B.

      -> and

    • C.

      BEGIN and END

    • D.

      ( and )

    Correct Answer
    A. { }
    Explanation
    The punctuation used to signal the beginning and end of code blocks is { }. This is commonly used in programming languages like C, C++, Java, and JavaScript. The opening curly brace { signifies the start of a code block, while the closing curly brace } signifies the end of the code block. This helps in organizing and structuring the code by defining the scope of the block and making it easier to read and understand.

    Rate this question:

  • 4. 

    What punctuation ends most lines of C++ code?

    • A.

      . (dot)

    • B.

      ; (semi-colon)

    • C.

      : (colon)

    • D.

      ' (single quote)

    Correct Answer
    B. ; (semi-colon)
    Explanation
    In C++ programming language, most lines of code are ended with a semi-colon (;). This punctuation is known as a statement terminator and it indicates the end of a line of code. It is important to include the semi-colon at the end of each line in order for the code to be properly compiled and executed.

    Rate this question:

  • 5. 

    Which of the following is a correct comment?

    • A.

      */ Comments */

    • B.

      ** Comment **

    • C.

      /* Comment */

    • D.

      { Comment }

    Correct Answer
    C. /* Comment */
    Explanation
    The correct comment is "/* Comment */". This is because comments in programming languages are typically denoted by using a specific syntax, such as "//" or "/* */". In this case, the comment is enclosed within "/* */", making it the correct option.

    Rate this question:

  • 6. 

    Which of the following is not a correct variable type?

    • A.

      Float

    • B.

      Real

    • C.

      Int

    • D.

      Double

    Correct Answer
    B. Real
    Explanation
    The variable type "real" is not a correct variable type. In most programming languages, "real" is not a valid keyword for defining variables. Instead, the correct keyword for representing decimal numbers is "float" or "double". The other options listed (float, int, and double) are all valid variable types commonly used in programming.

    Rate this question:

  • 7. 

    Which of the following is the correct operator to compare two variables?

    • A.

      :=

    • B.

      =

    • C.

      Equal

    • D.

      ==

    Correct Answer
    D. ==
    Explanation
    The correct operator to compare two variables is ==. This operator checks if the values of the two variables are equal.

    Rate this question:

  • 8. 

    Which of the following is true?

    • A.

      1

    • B.

      66

    • C.

      .1

    • D.

      -1

    • E.

      All of the above

    Correct Answer
    E. All of the above
    Explanation
    The answer "All of the above" is correct because all the options listed (1, 66, .1, -1) are true. Each option represents a different numerical value, but they are all valid and true in their own right. Therefore, the statement "All of the above" accurately reflects the truth of each individual option.

    Rate this question:

  • 9. 

    Which of the following is the boolean operator for logical-and?

    • A.

      &

    • B.

      &&

    • C.

      |

    • D.

      |&

    Correct Answer
    B. &&
    Explanation
    The boolean operator for logical-and is "&&". It is used to combine two boolean expressions and returns true if both expressions are true, otherwise it returns false.

    Rate this question:

  • 10. 

    Evaluate !(1 && !(0 || 1)).

    • A.

      True

    • B.

      False

    • C.

      Unevaluatable

    Correct Answer
    A. True
    Explanation
    The expression !(1 && !(0 || 1)) can be evaluated as follows:
    First, the innermost parentheses (0 || 1) evaluate to true because it represents the logical OR operation between 0 (false) and 1 (true).
    Next, the expression !(0 || 1) evaluates to false because it represents the logical NOT operation on the result of the previous step.
    Finally, the expression !(1 && !(0 || 1)) evaluates to true because it represents the logical NOT operation on the result of the logical AND operation between 1 (true) and the previous step (false). Therefore, the correct answer is True.

    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 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 01, 2011
    Quiz Created by
    Allcompiler
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.