I have some piece of code which I used for making some zeros on Matrix Array to 1 and printing it. I am making 4 0s to 1 in first while, but it says there are 5 1s on the array on second loop. Could not figure it out. Can you explain what is wrong in my code. Thanks for your time
#include <stdio.h>
main(){
int n;
printf("Desenin buyuklugunu giriniz: ");
scanf("%d",&n);
int satirlar[n][n]= {0};
int i=0, j=n-1;
while(i<(n/2) && j>n/2) {
satirlar[i][j] = 1;
i++;
j--;
}
for(int i=0; i< n; i++) {
for(int j=0; j< n; j++) {
if(satirlar[i][j] == 1) {
printf("*");
}
else printf("k");
}
printf("\n");
}
}
I Print "k" for seeing how many times loop worked. I get an output like this.
kkkk
kkkkk
arris never initialized to all zeroes.&&is the logical AND in c