Which of the following is the correct High level code for the given TAC in the…
2025

Which of the following is the correct High level code for the given TAC in the passage-
1- t1 = y+2
init = x/t1;
limit=10;
if(i>j || num>b)
{
num = limit-1;
b = y + 2;
i = i - num;
}
j = i - num;
k = k+b;
2- init = x/(y+2);
limit=10;
while(i>j || num>b)
{
num = limit-1;
b=y+2;
i=i-num;
}
j = i - num;
k = k+b;
3- init = x/(y+2);
limit=10;
if (i >j)
{
while(num>b)
num = limit-1;
}
else
{
b = y + 2;
i=i-num;
}
j = i - num;
k=k+b;
4-
init = x/(y+2);
limit=10;
while(i>j && num>b)
{
num = limit-1;
b=y+2;
i=i-num;
}
j = i - num;
k = k+b;
- A.
1
- B.
2
- C.
3
- D.
4
Attempted by 55 students.
Show answer & explanation
Correct answer: D
To solve this, we must reconstruct the logic from the TAC steps found in the original exam passage. The TAC generally follows this structure:
Identify the Loop: The TAC contains a statement like 110: goto 103, where line 103 is the start of the condition checks. This backward jump indicates a while loop rather than a simple if statement. This eliminates Options 1 and 3.
Analyze the Conditions (Logic Gate): The control flow in the passage is:
103: if i > j goto 105 (If true, proceed to next check. If false, exit loop).
105: if num > b goto 107 (If true, enter loop body. If false, exit loop).
Since the code requires both conditions (i > j AND num > b) to be true to reach the loop body (line 107), this represents the logical AND (&&) operator.
If it were || (OR), the code would jump directly to the body if the first condition was true.
Since it proceeds to a second check, it is &&.
Conclusion: The construct combines a while loop with an && condition, matching Option 4: while(i>j && num>b).
A video solution is available for this question — log in and enroll to watch it.