Is that code for the second while loop? Then yes it would work in some cases. However, you still have the problem of two possibly different values. That is, the first while loop prints the top half of the "picture", and happens i=3 times. The second while loop prints the bottom half of the picture, and happens j=? times (may be 3, in which case the picture will be symmetric and correct, otherwise it wont be). Basically, move the declaration of j up and have something like this (my changes are in red):
Code:
int main (int argc, char * argv[]) {
int j;
j = // get the value from the user, or simply assign it a value, or whatever way you want
int i;
i = j;
while (i >= 0) {
print_line(i*2, i*2+2);
i = i - 1;
}
i = 1;
while (i <= j) {
print_line(i*2, i*2+2);
i = i + 1;
}
return 0;
}
I havent tried it out, but I think it should work. Let us know if you have problems still.