Social Sciences, asked by vshal260, 1 year ago

Predict the output of following code.
int f = 1, i = 2;
do {
f* = 1;
} while(++i<5);
cout< (A) 12
(B) 5
(C) 4
(D) 24
Answer – D

Answers

Answered by Anonymous
0

in the first step i = 2 and f = 1

++i means i = i + 1

=> i = 2+1 = 3

since it is less than 5 so the loop executes, i.e

f* = i which is a short representation of

f = f * i

=> f = 1 * 3 = 3

again

i = i + 1

=> i = 3 + 1 = 4

since it is also less than 5 hence the loop executes again, i.e

f = f * i

=> f = 3 * 4 = 12

Now in the next increment,

i = 4+1 = 5

which is not less than 5 , so the loop will not execute any further

Hence the final value of f will be 12

Answered by Anonymous
2

&lt;b&gt;

HeYaA mAtE

Here is your answer:-

___________________________

▇ ▅ █ ▅ ▇ ▂ ▃ ▁ Option A▁ ▅ ▃ ▅ ▅ ▄ ▅ ▇

____________________________

==>> Because this option match's the most from your answer.

==>> This is the right option for your question.

==>> Mark it as brain list .

Hope it helps you

Thanks

Similar questions