x = 3;
y = 2;
result = 0;
counter = y;
while(counter > 0)
{
result = result + x;
counter = counter - 1;
}
print(result);
What would be the output?
Ok first iteration
counter = 2,result = 0 + 3 == 3
second iteration
counter = 1, result = 3 + 3 == 6
third iteration
counter = 0, break out of loop print result
result == 6
result = 3
counter = 1
Examine the code snippet below
x = 3;
y = 2;
result = 0;
counter = y;
while(counter > 0)
{
result = result + x;
counter = counter - 1;
}
print(result);
What would be the output?