I'm trying to print an array of 3x3 and placing random numbers within them that has no repetition. I think what I did was right but there just isn't any output. I know I can easily get the answer somewhere but I would like to know what is wrong with my code. Can anyone help me? Sorry if it is hard to read my code.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
int i,j,k,l; //loop initilizers
int count; //to check for repetition
int num;
int grid[3][3] = {};
srand(time(NULL));
num = 1 + rand()%9;
//generating the array & checking for repetition
for(i=1;i=3;i++)
{
for(j=1;j=3;j++)
{
for(k=1;k=3;k++) //checking the row for repetition
{
if(grid[k][j]=num)
count++;
}
for(l=1;l=3;l++) //checking the column for repetition
{
if(grid[i][l]=num)
count++;
}
if(count<1)
{ //if number isn't found in either row or column,
grid[i][j]=num; //set the number into array
}
else
{
grid[i][j]=10;
}
}
}
for(i=1; i=3; i++) //printing the array
{
for(j=0; j=3; j++)
printf("%d ", grid[i][j]);
}
return 0;
}