Vous êtes sur la page 1sur 3

Manual # 10

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<<"Enter the Size: ";


cin>>size;

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";

cout<<"Enter Data to search: ";


cin>>data;

for(k=0;k<size;k++)
{
if(data==i[k])
{
cout<<"Data Found"<<endl;
goto end;
}
}

cout<<"Data Not Found"<<endl;

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.
------------------------------------------------------------------------------------------------------------

Vous aimerez peut-être aussi