#include <stdio.h>
int main(){
int i,j;
int flag = 0;
int x [3][3] = {{1,2,3},{4,5,6},{7,8,9}};
for (i = 0;i<3;i++){
if (flag ==1){
for (j=2;j<0;j--){
printf(" %d",x[i][j]);
}
flag =0;
}
else {
for (j=0;j<3;j++)
{
printf(" %d ",x[i][j]);
}
flag =1;
}
}
return 0;
}
i'm trying to print the numbers in the array in a zigzag form the expected output should be 123654789 but all i got 123789 for some reason i dont enter the loop in the flag condition i want to know the reason.. thanks in advance