Questions with Answers on Pre-Post Operators For 9/10th class Java/C++ Students

State the value of a, b and c after the execution of each of the following statements where a=12, b=13 and c=11:

  1. a=a++ + –b + c++

Ans. a=35, b=12, c=12

  1. b=b++ + ++a * 2

Ans. a=13, b=39, c=11

  1. c=c++ + a++ * (++b)

Ans. a=13, b=14, c=179

  1. b=b++ + ++b + c++ + ++a

Ans. a=13, b=52, c=12

  1. a= –a + b++ + ++a + – –b * c++

Ans. a=179, b=13, c=12

  1. a+=a++ + ++b – c++

Ans. a=27, b=14, c=12

  1. b+= – –c + ++c + a++ + (b++)

Ans. a=13, b=59, c=11

  1. c+=a– – + – –a + (b++) * (++b)

Ans. a=10, b=15, c=228

  1. a+=a++ + ((++b)/2)

Ans. a=31, b=14, c=11

 

Give the output of the following method:

int test()

{

int a = 5;

a++;

a-=(a–)-(–a);

return a;

}

Ans.     4

This entry was posted in 9/10th Class Students and tagged , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

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