heres the code
the method is linear search and the values of n and the array elements are taken as input from the user ina separt functn. I can always help if u want the entire prog.
specify the array length.
complete the prog before complin.
# include%26lt;iostream.h%26gt;
# include%26lt;conio.h%26gt;
void main()
{int A[], data, n,ch=0,i;
while((i%26lt;n)%26amp;%26amp;(ch==0))
{if (data==A[i])
ch++;
else i++;
}
if (ch)
cout%26lt;%26lt;"position of the element is"%26lt;%26lt;(i+1);
else
cout%26lt;%26lt;"data not present"%26lt;%26lt;endl;
getch();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment