ICSE Class 10 Computer Applications Question 24 of 30

Solved Sample Paper 2 — Question 24

Back to all questions
24
Question

Question 2(iv)

Write the values that will be stored in variables num and sum after execution of the following code.

int sum = 0, num = -2;
do
{
    sum = sum + num; 
    num++;
} while (num < 1);
Answer

After the execution of the given code, num = 1 and sum = -3