How to trace output?
How to trace output of this program?
I don't understand how to trace the output
It shows
1
0
0
0
0
2
0
0
0
0
3
0
0
0
0
4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include<stdio.h>
#include<stdlib.h>
#pragma warning (disable:4996)
main(void) {
int i = 1, j;
while (i <= 4) {
j = 1;
while (j <= 4) {
if (i == j)
printf("%d\n", j);
else
printf("0\n");
j = j + 1;
}
i = i + 1;
}
system("pause");
}
|
Write a numbered list of all the steps the code is making or make a flow chart, that helps me. e.g.
I would write "1. The computer makes an int called i equal to 1 and an int called j
Thanks :)
Use the debugger for your compiler. MS VS has an in-built one within its IDE.
Topic archived. No new replies allowed.