Question:

In a statement $c = c + (x * d + e);$ which variable is an accumulator?

Show Hint

An accumulator variable usually appears on both sides of the assignment, like \textbf{sum = sum + value}. That repeated updating is the key sign.
  • d
  • c
  • e
  • x
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

Step 1: Understand the meaning of accumulator.
An accumulator is a variable that stores a running total. It usually appears on both sides of an assignment statement because its old value is used and then updated with a new value.
Step 2: Examine the given statement.
The statement is: \[ c = c + (x * d + e) \] Here, the old value of c is taken first. Then some new quantity \((x*d+e)\) is added to it. After that, the result is stored again in c.
Step 3: Identify the accumulator variable.
Since c is the variable that keeps collecting the updated value repeatedly, it acts as the accumulator. The other variables \(x\), \(d\), and \(e\) are only used in the calculation and are not storing the running total.
Step 4: Conclusion.
Therefore, the accumulator variable in the given statement is c.
Final Answer:c.
Was this answer helpful?
0
0

Questions Asked in ICSE Class X board exam

View More Questions