Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 7

Basics of C++ Set 1

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

C. 0

Question 2.What is the only function all C++ programs must contain?
C. main()

Question 3.What punctuation is used to signal the beginning and end of code
blocks?
A. { }

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


B. ; (semi-colon)

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


C. /* Comment */

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


B. real

Question 7.Which of the following is the correct operator to compare two variables?
l
D. ==

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


B. &&

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


A. True

Set 2
Question 1Identify the correct statement

b. All lines beginning with two slash signs are considered


comments.

Question 2 The directives for the preprocessors begin with

c. Number Sign (#)


Question 3 The file iostream includes

a. The declarations of the basic standard input-output library.

Question 4

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

c. Main()

Question 5

Every function in C++ are followed by

b. Parenthesis

Question 6Which of the following is true

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

Question 7

Every statement in C++ program should end with

c. A Semicolon

Question 8 Which of the following statement is true about preprocessor


directives?

d. They end with a semicolon

Question 9A block comment can be written by

b. Starting with /* and ending with */

Question 10 When writing comments you can

b. Use code and // comments on the same line


Set 4
Question 1 In an assignment statement
a=b;
Which of the following statement is true?
b. The value of b is assigned to variable a but the later changes on variable b will
not effect the value of variable a

Question 2 All of the following are valid expressions in C++


a = 2 + (b = 5);

a = b = c = 5;

a = 11 % 3

a. True

Question 3:
To increase the value of c by one which of the following statement is wrong?

a. c++;

b. c = c + 1;

d. c += 1

Question 4:
When following piece of code is executed, what happens?

b = 3;

a = b++;

a. a contains 3 and b contains 4

Question 5:
The result of a Relational operation is always

a. either True or False

Question 6:
Which of the following is a valid relational operator?
a. == , >=

Question 7:
What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run?

A. 10

Question 8:
When does the code block following while(x<100) execute?

A. When x is less than one hundred

Question 9:Which is a loop structure?


A. for

B. do while

C. while

Question 10:
How many times is a do while loop guaranteed to loop?

C. 1

Set 3
Question 1 A variable is/are

b. A portion of memory to store a determined value

Question 2 Which of the following can be used as identifiers?

a. Letters

b. Digits

c. Underscores
Question 3 Which of the following identifiers is valid?

a. papername

b. writername

d. printname

Question 4 Which of the following can be used as valid identifier?

b. bittand

c. biand

d. band

Question 5 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

Question 6Which of the following is a valid escape code?

a. \t

b. \v

c. \f

Question 7

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

Question 8 Regarding #define which of the following statement is true?

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

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

Question 9 Regarding following statement which of the statements is true?


const int pathwidth=100;

c. Declares a constant pathwidth whose value will be 100

Question 10

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

http://www.psexam.com/Multiple-Choice-Questions-MCQs-from-C++/c-plus-plus-
mcq-ebook-download.html

Answers

1. b. A portion of memory to store a determined value


2. d. Spaces

3. c. Typename

4. a. Bitand

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

6. d. \w

7. d. All of above

8. c. It is a C++ statement that declares a constant in C++

9. c. Declares a constant pathwidth whose value will be 100

10. d. All of above

You might also like