Thursday 17 January 2013

Linear search c plus plus program

| |


#include<iostream>

using namespace std;
int main()
{ int sc[100],n,count=0,y;
cout<<"How many numbers u want to enter?";
cin>>y;
cout<<"Enter the numbers";

for(int i=0; i<y; i++)
{cin>>sc[i];}
cout<<"Enter a number for the query! ";
cin>>n;
for(int j=0; j<y;j++)
{if(sc[j]==n)
{
count=count+1;
}}
if(count==1)
{
            cout<<"The requred query "<<n<<" is found! \n";
            }
else
{
cout<<"The required query cannot be found! \n";}

system ("pause");
return 0;}


Linear search c plus plus program


Related Posts Plugin for WordPress, Blogger...
Powered by Blogger.