Académique Documents
Professionnel Documents
Culture Documents
Topic:
Searching Techniques Using Arrays
Subject:
Introduction to Computing
Author:
Engr. Ali Faisal Murtaza
1
------------------------------------------------------------------------------------------------------------
Linear Search through Arrays
#include<iostream.h>
int main()
{
int i[100],size,data,k;
cout<<"\n";
cout<<"Enter Data:"<<endl;
for(k=0;k<size;k++)
{
cin>>i[k];
}
cout<<"\n";
for(k=0;k<size;k++)
{
cout<<i[k]<<" --> ";
}
cout<<"\n\n";
for(k=0;k<size;k++)
{
if(data==i[k])
{
cout<<"Data Found"<<endl;
goto end;
}
}
end:
cout<<"\n\n";
2
return 0;
}
------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
Q1: Duplication: Write a program which will take the value from the user and in case
user entered the duplication value then the programs tells that duplicate value is entered
and then after entering the value the program should be able to find out the value.
------------------------------------------------------------------------------------------------------------
Q2: Do Binary Search through Arrays
------------------------------------------------------------------------------------------------------------
Q3: Write a program which will find the element from any given matrix.
------------------------------------------------------------------------------------------------------------