Sail E0 Webinar

MCQs

Total Questions : 10
Question 1.

Which concepts does the preincrement uses?


  1.    call by value
  2.    call by reference
  3.    queue
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> call by reference

None.


Question 2.

Pick out the correct statement


  1.    Preincrement is faster than postincrement.
  2.    postincrement is faster than preincrement.
  3.    Both a & b
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> Preincrement is faster than postincrement.

Because preincrement take one byte instruction & post increment takes two byte instruction


Question 3.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int num1 = 5;
6.
int num2 = 3;
7.
int num3 = 2;
8.
num1 = num2++;
9.
num2 = --num3;
10.
cout
  1.    532
  2.    235
  3.    235
  4.    311
 Discuss Question
Answer: Option D. -> 311

In this program, We are preincrementing and postincrementing the operands and saving it.
Output:
$ g++ incre5.cpp
$ a.out
311


Question 4.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int x = 5, y = 5, z;
6.
x = ++x; y = --y;
7.
z = x + ++x;
8.
cout
  1.    11
  2.    12
  3.    13
  4.    14
 Discuss Question
Answer: Option D. -> 14

In this program, we are adding the x value after preincrementing two times.
Output:
$ g++ incre4.cpp
$ a.out
14


Question 5.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int x = 5, y = 5, z;
6.
x = ++x; y = --y;
7.
z = x++ + y--;
8.
cout << z;
9.
return 0;
10.
}
  1.    10
  2.    11
  3.    9
  4.    12
 Discuss Question
Answer: Option A. -> 10

In this program, the increment and decrement of evaluation of z will not be accounted because they are post.
Output:
$ g++ incre3.cpp
$ a.out
10


Question 6.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int x = 5, y = 5;
6.
cout
  1.    55
  2.    64
  3.    46
  4.    45
 Discuss Question
Answer: Option B. -> 64

The values will be preincemented and predecremented, So it will print as 64.
Output:
$ g++ incre2.cpp
$ a.out
64


Question 7.

How many types are there in increment/decrement operator?


  1.    1
  2.    2
  3.    3
  4.    4
 Discuss Question
Answer: Option B. -> 2

There are two types of increment/decrement. They are postfix and prefix.


Question 8.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int a = 21;
6.
int c ;
7.
c = a++;
8.
cout
  1.    21
  2.    22
  3.    23
  4.    20
 Discuss Question
Answer: Option A. -> 21

Explanation:value of 'a' will be stored in c and then only it will be incremented.
Output:
$ g++ incre.cpp
$ a.out
21



Question 9.

Pick out the correct statement.


  1.    Increment operator ++ adds 1 to its operand
  2.    Increment operator ++ adds 2 to its operand
  3.    Decrement operator ++ subtracts 1 to its operand
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> Increment operator ++ adds 1 to its operand

None.


Question 10.

Which operator works only with integer variables?


  1.    increment
  2.    decrement
  3.    both a & b
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> both a & b

None.


Latest Videos

Latest Test Papers