C++ Basic MCQ Questions And Answers

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Allcompiler
A
Allcompiler
Community Contributor
Quizzes Created: 4 | Total Attempts: 23,509
| Attempts: 5,455
SettingsSettings
Please wait...
  • 1/10 Questions

    A variable is/are

    • A string that varies during program execution
    • A portion of memory to store a determined value
    • Those numbers that are frequently required in programs
    • None of these
Please wait...
About This Quiz

Get ready for these C++ basic MCQ questions and answers. This quiz is created for those users who want to test their command over the C++ Programming Language. The quiz is gonna be helpful to learn even more about C++ in a fun way. You will be called an expert in this subject if you manage to get more than See more70 on this quiz. So, are you ready and excited? Let's go for it!


C++ Basic MCQ Questions And Answers - Quiz

Quiz Preview

  • 2. 

    Which of the following cannot be used as identifiers?

    • Letters

    • Digits

    • Underscores

    • Spaces

    Correct Answer
    A. Spaces
    Explanation
    Spaces cannot be used as identifiers because in most programming languages, identifiers are used to represent variables, functions, or other entities in the code. Spaces are not allowed because they can cause ambiguity and confusion in the code. Instead, developers typically use underscores or camel case to separate words within an identifier.

    Rate this question:

  • 3. 

    Which of the following identifiers is invalid?

    • Papername

    • Writername

    • Typename

    • Printname

    Correct Answer
    A. Typename
    Explanation
    The identifier "Typename" is invalid because it starts with an uppercase letter, which is not allowed in most programming languages. Identifiers usually start with a lowercase letter or an underscore.

    Rate this question:

  • 4. 

    Which of the following cannot be used as a valid identifier?

    • Bitand

    • Bittand

    • Biand

    • Band

    Correct Answer
    A. Bitand
    Explanation
    The identifier "bitand" cannot be used as a valid identifier because it is a reserved keyword in many programming languages, including C++, C#, and Java. Reserved keywords have a predefined meaning in the language and cannot be used as identifiers for variables, functions, or other elements in the code. Using "bitand" as an identifier would result in a syntax error.

    Rate this question:

  • 5. 

    The difference between x and ‘x’ is

    • The first one refers to a variable whose identifier is x and the second one refers to the character constant x

    • The first one is a character constant x, and second one is the literal string x

    • Both are same

    • None of above

    Correct Answer
    A. The first one refers to a variable whose identifier is x and the second one refers to the character constant x
    Explanation
    The correct answer is that the first one refers to a variable whose identifier is x and the second one refers to the character constant x. This means that the first one is a variable that can hold a value, while the second one is a specific character constant.

    Rate this question:

  • 6. 

    Which of the following is not a valid escape code?

    • \t

    • \v

    • \f

    • \w

    Correct Answer
    A. \w
  • 7. 

    Which of the following statement is true?

    • String Literals can extend to more than a single line of code by putting a backslash sign at the end of each unfinished line.

    • You can also concatenate several string constants, separating them by one or several blank spaces, tabulators, newlines, or any other valid blank character.

    • If we want the string literal to explicitly made of wide characters, we can precede the constant with the L prefix.

    • All of above

    Correct Answer
    A. All of above
    Explanation
    All of the statements given are true. String literals can extend to more than a single line of code by using a backslash at the end of each unfinished line. Multiple string constants can be concatenated by separating them with blank spaces, tabulators, newlines, or any other valid blank character. If we want the string literal to be explicitly made of wide characters, we can use the L prefix. Therefore, the correct answer is "All of above."

    Rate this question:

  • 8. 

    Regarding #difine, which of the following statement is false?

    • It is not a C++ statement but the directive for the preprocessor.

    • This does not require a semicolon at the end of line.

    • It is a C++ statement that declares a constant in C++.

    • None of the above

    Correct Answer
    A. It is a C++ statement that declares a constant in C++.
    Explanation
    The statement "It is a C++ statement that declares a constant in C++" is false. The correct answer is that #define is not a C++ statement but the directive for the preprocessor. #define is used to define constants or macros in C++ and is processed by the preprocessor before the actual compilation of the code. It does not require a semicolon at the end of the line.

    Rate this question:

  • 9. 

    Regarding the following statement, which of the statements is true? const int pathwidth=100;

    • Declares a variable pathwidth with 100 as its initial value

    • Declares a construction pathwidth with 100 as its initial value

    • Declares a constant pathwidth whose value will be 100

    • Constructs an integer type variable with pathwidth as identifier and 100 as value

    Correct Answer
    A. Declares a constant pathwidth whose value will be 100
    Explanation
    The given statement "const int pathwidth=100;" declares a constant variable named pathwidth with an initial value of 100.

    Rate this question:

  • 10. 

    In an assignment statement

    • The value must always be a variable.

    • The value might be a constant, a variable, an expression, or any combination of these.

    • The assignment always takes place from right to left and never the other way.

    • All of above

    Correct Answer
    A. All of above
    Explanation
    The correct answer is "All of above". This is because in an assignment statement, the value can be a constant, a variable, an expression, or any combination of these. The assignment always takes place from right to left and never the other way. Therefore, all the statements mentioned in the options are correct.

    Rate this question:

Quiz Review Timeline (Updated): Apr 21, 2023 +

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

  • Current Version
  • Apr 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 15, 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.