Computer Science, asked by rajpoot220799, 4 months ago

What will be the output of the following pseudo code?
integer a=1,b=2;
for(int i=0; i<=6; i=i+2)
a=a+b+i
a=a+b;
bra-b;
Print b
End for

Answers

Answered by skumarsep5
2

Answer:

11

Explanation:

Integer a ,b 2. Set a = 10, b = 7 3. for(int i = 1; i <= 5; i++) ... a = a + b b = b 1 6. 7. 8. a = a 9. 10. end while. Print a. End for 11. ...

Answered by qwsuccess
0

Output: 3 10 27 70

  1. In the first iteration, a=1 and b=2 and i=0. So inside the loop in the first line a becomes equal to 3 (1+2+0) and in the next line a becomes equal to 5 (3+2). Finally, b becomes equal to 3 (5-2) and the current value of b is printed (=3).
  2. In the second iteration, a=5 and b=3 and i=2 (i gets increased by 2). So inside the loop in the first line a becomes equal to 10 (5+3+2) and in the next line a becomes equal to 13 (10+3). Finally, b becomes equal to 10 (13-3) and the current value of b is printed (=10).
  3. This goes on similarly for two more iterations for i=4 and i=6 and values of b are printed (27 and 70).
  4. So, the output is 3 10 27 70 according to the values of b.
Similar questions