Search This Blog

Saturday, 1 January 2022

Title :- linear Search

 Title :- linear Search


Program:

#include<iostream>
using namespace std;
int main()
{
    int n,x,i,flag=0,a[10];
    cout<<"Enter the no.of.Elements: ";
    cin>>n;
    cout<<"Enter the elemnts of aarrray: ";
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    cout<<"Enter the elemets for the searching: ";
    cin>>x;
    for(i=0;i<n;i++)
    {
        if(a[i]==x)
            flag=1;
        else
            flag=0;
    }
    if(flag==1)
        cout<<"Elments is found";
    else
        cout<<"Elements is not found";
    return 0;
}

No comments:

Post a Comment

Search This Blog

Contact Form

Name

Email *

Message *

Popular Posts