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-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 -3

    Question 1: Find out the error in following block of code. If (x = 100)     Cout << ΓÇ£x is 100ΓÇ¥; a.       100 should be enclosed in quotations b.      There is no semicolon at the end of first line c.       Equals to operator mistake d.      Variable x should not be inside quotation   Question 2:…

  • C++ MCQ-16

    Q.91   What will be the result of the expression 13 & 25? (A) 38  (B)  25 (C)  9  (D)  12      Ans:C  Q.92   Which of the following operator can be overloaded through friend function? (A)  ->   (B)  = (C)  ( )   (D)  *        Ans:D   Q.93  To access the public function…

  • C++ MCQ -5

    Question 1 Streams are a.       Abstraction to perform input and output operations in sequential media b.      Abstraction to perform input and output operations in direct access media c.       Objects  where a program can either insert or extract characters to and from it d.      Both a and c   Question 2 Which of the following is…

  • 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…

Leave a Reply

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