Question 31 asks for the output of a given pseudo code. The pseudo code initializes a variable $B$ to 1. Then, it iterates through a loop where $A$ goes from 2 to 8 with a step of 2. Inside the loop, $B$ is updated by adding $A$ to it ($B = B + A$), and then the value of $B$ is displayed.
2025/7/13
1. Problem Description
Question 31 asks for the output of a given pseudo code. The pseudo code initializes a variable to
1. Then, it iterates through a loop where $A$ goes from 2 to 8 with a step of
2. Inside the loop, $B$ is updated by adding $A$ to it ($B = B + A$), and then the value of $B$ is displayed.
2. Solution Steps
First, initialize .
The loop runs for .
- When : . Display , which is
3. - When $A = 4$: $B = B + A = 3 + 4 = 7$. Display $B$, which is
7. - When $A = 6$: $B = B + A = 7 + 6 = 13$. Display $B$, which is
1
3. - When $A = 8$: $B = B + A = 13 + 8 = 21$. Display $B$, which is
2
1.
So, the output is 3, 7, 13,
2
1.
3. Final Answer
(4) 3, 7, 13, 21