C++ MCQ -6

Question 1

In an assignment statement

a=b;

Which of the following statement is true?

a.    The variable a and the variable b are equal.

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

c.    The value of b is assigned to variable a and the later changes on variable b will effect the value of variable a

d.    The value of variable a is assigned to variable b and the value of variable b is assigned to 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

b.    False

 

 
Question 3:

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

a.    c++;

b.    c = c + 1;

c.    c + 1 => c;

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

b.    a contains 4 and b contains 4

c.    a contains 4 and b contains 3

d.    a contains 3 and b contains 3

 

 
Question 5:

The result of a Relational operation is always

a.    either True or False

b.    is less than or is more than

c.    is equal or less or more

d.    All of these

 

 
Question 6:

Which of the following is not a valid relational operator?

a.    ==

b.    =>

c.    >=

d.    >=

 
Question 7:

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

A. 10

B. 9

C. 0

D. 1

 

 
Question 8:

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

A. When x is less than one hundred

B. When x is greater than one hundred

C. When x is equal to one hundred

D. While it wishes

 

 
Question 9:

Which is not a loop structure?

A. for

B. do while

C. while

D. repeat until

 

 
Question 10:

How many times is a do while loop guaranteed to loop?

A. 0

B. Infinitely

C. 1

D. Variable

Answers

 

1.    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

2.    a. True

3.    c. c + 1 => c;

4.    a. a contains 3 and b contains 4

5.    a. either True or False

6.    b. =>

7.    A. 10

8.    A. When x is less than one hundred

9.    D. Repeat Until

10.    C. 1

Similar Posts

  • C++ MCQ-10

    Q.16   If we create a file by ΓÇÿifstreamΓÇÖ, then the default mode of the file is _________    (A)  ios :: out  (B)  ios :: in (C)  ios :: app  (D)  ios :: binary     Ans: B   Q.17   A variable defined within a block is visible        (A) from the point of…

  • C++ MCQ -2

    Question 1: The void specifier is used if a function does not have return type. a.       True b.      False   Question 2: You must specify void in parameters if a function does not have any arguments. a.       True b.      False   Question 3: Type specifier is optional when declaring a function a.       True b.      False…

  • C++ MCQ -8

    Question 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. both   Question 2 The directives for the preprocessors begin with a.   …

  • C++ MCQ-14

    Q.61  An array element is accessed using (A)  a FIFO approach  (B)  an index number (C)  the operator  (D)  a member name     Ans:B   Q.62   If there is a pointer p to object of a base class and it contains the address of an object of a derived class and both classes contain…

  • C++ MCQ-15

    Q.76   Which of the following expressions is illegal? (A)  ( ) 6 10 .  (B)  (false && true) (C)  bool (x) = (bool)10;  (D)  float y = 12.67;       Ans:C   Q.77  The actual source code for implementing a template function is created when   (A) The declaration of function appears. (B) The…

Leave a Reply

Your email address will not be published. Required fields are marked *