CPP

CPP

Increment and Decrement has 9 Questions

Which operator works only with integer variables?

increment
decrement
both a & b
None of the mentioned
How many types are there in increment/decrement operator?

1
2
3
4
Pick out the correct statement.

Increment operator ++ adds 1 to its operand
Increment operator ++ adds 2 to its operand
Decrement operator ++ subtracts 1 to its operand
None of the mentioned
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 << c;  
  9.         return 0;
  10.     }

21
22
23
20
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.     }

10
11
9
12
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 << z;
  9.         return 0;
  10.     }

11
12
13
14
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 << num1 << num2 << num3;
  11.         return 0;
  12.     }

532
235
312
311
Pick out the correct statement

Preincrement is faster than postincrement.
postincrement is faster than preincrement.
Both a & b
None of the mentioned
Which concepts does the preincrement uses?

call by value
call by reference
queue
None of the mentioned