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

    Question 1. What is the correct value to return to the operating system upon the successful completion of a program? A. -1 B. 1 C. 0 D. Programs do not return a value.   Question 2. What is the only function all C++ programs must contain? A. start() B. system() C. main() D. program()  …

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

    Question 1: A function can not be overloaded only by its return type. a. True b. False   Question 2: A function can be overloaded with a different return type if it has all the parameters same. a. True b. False   Question 3: Inline functions involves some additional overhead in running time. a. True…

Leave a Reply

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