C Programming20805 marksNumerical: trace loop outputDecision Making and Looping
Trace the output ```c #include <conio.h> #include <stdio.h> void main() { int i = 0, k; for (k = 5; k >= 0; k--) { i = i + k; } printf("%d\t", i); getch(); } ```
Trace the output
#include <conio.h>
#include <stdio.h>
void main() {
int i = 0, k;
for (k = 5; k >= 0; k--) {
i = i + k;
}
printf("%d\t", i);
getch();
}
[5]
Initial value: $i = 0$ --- The loop starts at $k = 5$, decrements by 1 each pass, and continues while $k \geq 0$. Iteration $k$ Condition $k \geq 0$ $i = i + k$ New $i$ ------------------------------------------------------------ 1 5 True $0 + 5$ 5 2 4 True $5 + 4$ 9 3 3 True $9 + 3$ 12 4 2 True ...