Aim: - To search an element in the 2-dimensional array using Linear Search.

 

#include<stdio.h> #include<conio.h> void main()

{

int a[3][3],i,j,item,flag=0; clrscr();

printf("Enter the data in the array"); for(i=0;i<3;i++)

{

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

{

scanf("%d",&a[i][j]);

}

}

printf("Enter the element to be searched"); scanf("%d",&item);

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

{

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

{

if(item==a[i][j])

{

flag=1;

printf("Element found at position =%d,%d",i,j);

}

}

}

if(flag==0)

printf("Element Not Found");

 

getch();

}