C++ MCQ Questions

C++ MCQ Questions
Play C++ Quiz
C++ MCQ Quiz 1 (Basic)
C++ Quiz 2 (Function-Class)
Ad. C++ Quiz 3 (OOP-Function-Class-Object)

As we know C++ MCQ Quiz are very important for Computer Science and IT class student and also for IT job interview and entrance exam.

It has 3 mcq section questions set about various C++ subject with function of C++,  OOP funciton of C++ and Class object. Let’s get started.

Return to Programming Language Quiz List

Complete C++ MCQ Quiz

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

(A) A. -1

(B) 1

(C) 0

(D) Programs do not return a value

View Answer
(C) 0

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

(A) start()

(B) system()

(C) main()

(D) program()

View Answer
(C) main()

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

(A) { }

(B) -> and <-

(C) BEGIN and END

(D) ( and )

View Answer
(A) { }

Question 4: What punctuation ends most lines of C++ code?

(A) . (dot)

(B) ; (semi-colon)

(C) : (colon)

(D) ‘ (single quote)

View Answer
(B) ; (semi-colon)

Question 5: Which of the following is a correct comment?

(A) */ Comments */

(B) ** Comment **

(C) /* Comment */

(D) { Comment }

View Answer
(C) /* Comment */

Question 6: Which of the following is not a correct variable type?

(A) float

(B) real

(C) int

(D) double

View Answer
(B) real

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

(A) :=

(B) =

(C) equal

(D) ==

View Answer
(D) ==

Question 8: Which of the following is true?

(A) 1

(B) 66

(C) .1

(D) -1

(E) All of the above

View Answer
(E) All of the above

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

(A) &

(B) &&

(C) |

(D) |&

View Answer
(B) &&

Question 10: Evaluate !(1 && !(0 || 1)).

(A) True

(B) False

(C) Unevaluable

(D) None

View Answer
(A) True

Question 11: 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

View Answer
(B) All lines beginning with two slash signs are considered comments.

Question 12: The directives for the preprocessor begin with __________ .

(A) Ampersand symbol (&)

(B) Two Slashes (//)

(C) Number Sign (#)

(D) Less than symbol (<)

View Answer
(C) Number Sign (#)

Question 13: 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

View Answer
(A) The declarations of the basic standard input-output library.

Question 14: There is a unique function in C++ program by where all C++ programs start their execution _________. 

(A) Start()

(B) Begin()

(C) Main()

(D) Output()

View Answer
Answer

Question 15: Every function in C++ are followed by ________ .

(A) Parameters

(B) Parenthesis

(C) Curly braces

(D) None of these

View Answer
(B) Parenthesis

Question 16: 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

View Answer
(D) None of above

Question 17: Every statement in C++ program should end with _______ .

(A) A full stop (.)

(B) A Comma (,)

(C) A Semicolon (;)

(D) A colon (:)

View Answer
(C) A Semicolon (;)

Question 18: 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

View Answer
(D) They end with a semicolon

Question 19: 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 <!- and ending with -!>

View Answer
(B) Starting with /* and ending with */

Question 20: 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 <!- comments on the same line

View Answer
(B) Use code and // comments on the same line

Question 21: A variable is/are _________ .

(A) String that varies during program execution

(B) A portion of memory to store a determined value

(C) Those numbers that are frequently required in programs

(D) None of these

View Answer
(B) A portion of memory to store a determined value

Question 22: Which of the following cannot be used as identifiers?

(A) Letters

(B) Digits

(C) Underscores

(D) Spaces

View Answer
(D) Spaces

Question 23: Which of the following identifiers is invalid?

(A) papername

(B) writername

(C) typename

(D) printname

View Answer
(C) typename

Question 24: Which of the following can not be used as valid identifier?

(A) bitand

(B) bittand

(C) biand

(D) band

View Answer
(A) bitand

Question 25: The difference between x and ‘x’ is __________ .

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

(B) The first one is a character constant x and second one is the string literal x

(C) Both are same

(D) None of above

View Answer
(A) The first one refers to a variable whose identifier is x and the second one refers to the character constant x

Question 26: Which of the following is not a valid escape code?

(A) \t

(B) \v

(C) \f

(D) \w

View Answer
(D) \w

Question 27: Which of the following statement is true?

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

(B) You can also concatenate several string constants separating them by one or several blank spaces, tabulators, newline or any other valid blank character

(C) If we want the string literal to explicitly made of wide characters, we can precede the constant with the L prefix

(D) All of above

View Answer
(D) All of above

Question 28: Regarding #difine which of the following statement is false?

(A) It is not C++ statement but the directive for the preprocessor

(B) This does not require a semicolon at the end of line

(C) It is a C++ statement that declares a constant in C++

(D) None of the above

View Answer
(C) It is a C++ statement that declares a constant in C++

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

(A) Declares a variable pathwidth with 100 as its initial value

(B) Declares a construction pathwidth with 100 as its initial value

(C) Declares a constant pathwidth whose value will be 100

(D) Constructs an integer type variable with pathwidth as identifier and 100 as value

View Answer
(C) Declares a constant pathwidth whose value will be 100

Question 30: In an assignment statement ____________.

(A) The lvalue must always be a variable

(B) The rvalue might be a constant, a variable, an expression or any combination of these

(C) The assignment always takes place from right to left and never the other way

(D) All of above

View Answer
(D) All of above