Actually, give an input.. at random .(no zero's)

the printf() which I highlighted is showing out of range array location..

why this is happening ..

To be specific..Code:# include <stdio.h> int main() { int n,i,j,flag; int arr[3][3]; printf("Enter arr\n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) { scanf("%d",&arr[i][j]); } } for (i=0;i<3;i++) { for(j=0;j<3;j++) { flag = 0; if (arr[i][j]==0) { printf("[%d,%d]",i,j); break; } else if (arr[i][j]!=0) { flag = 1; printf("<%d, %d>",i,j); } } }if (flag==1)}printf("/%d, %d/\n",i,j);

what I am looking for is that.. :

let us assume a number N and a array Arr[][]

now, if the array doesn't have the value N. it should print (say, not present)

if did this way.

where i am going wrongCode:for (i=0;i<3;i++) { for (j=0;j<3;j++) { flag = 0; if ( arr[i][j] == N) flag =1; } } if (flag ==1) { printf("not present"); printf("Last loc (%d %d)",i,j); //its showing out of range .. ie., showing 3 instead of //2 if no number is N }