Hi,,

I really confuse about a part of this program using for loop :

for(i=0; i<3; i++) {

for(j=0; j<3; j++)

if(matrix[i][j]==0) matrix[i][j]=no;

if(matrix[i][j]==0) matrix[i][j]=55;

++no;

}

Code:

#include <stdio.h>
int main(){
int matrix[3][3];
int i,j, no=1;
for(i=0; i<3; i++) {
for(j=0; j<3; j++){
matrix[i][j]=0;
}
}
for(i=0; i<3; i++) {
for(j=0; j<3; j++)
if(matrix[i][j]==0) matrix[i][j]=no;
if(matrix[i][j]==0) matrix[i][j]=55;
++no;
}
for(i=0; i<3; i++) {
for(j=0; j<3; j++) {
printf("%d ", matrix[i][j]);
if (j==2) printf("\n");
}
}
return 0;
}

it will output 1 1 1

55 2 2

55 3 3

I really confuse about the output >_< can you please explain to me how is the process in for loop so we get that output?

I think it must be 55 1 1

55 2 2

55 3 3

I really need the explanation ASAP XD ^^

Thank you ^^