English

Which of the answers does the same thing as the following: value += sum++;

Advertisements

Question

Which of the answers does the same thing as the following:

value += sum++;

Options

  • value = value + sum;
    sum = sum + 1;

  • sum = sum + 1;
    value = value + sum;

  • value = value + sum;

  • value = value + ++sum;

MCQ
Advertisements

Solution

value = value + sum;
sum = sum + 1;

Explanation:

The statement value += sum++; first adds the original value of sum to value and then increments sum by 1.

shaalaa.com
  Is there an error in this question or solution?
Chapter 6: Variables and Expressions - EXERCISE [Page 133]

APPEARS IN

Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 6 Variables and Expressions
EXERCISE | Q 44. | Page 133
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×