Thursday, 11 May 2017

C++ Tutorials for begginners (hindi/urdu) [part 21] - Array linear search







#include<constream.h>

#include<iomanip.h>

void main(){

clrscr();

 

    //ARRAYS Searching

    int numbers[5]={22,33,44,55,66};

    int search;

    int found = 0;

   

    cout<<"Enter number you want to search"<<endl;

    cin>>search;

   

    for(int i=0;i<5;++i)

    {

        if(numbers[i] == search){

            found = 1;

        }

    }//for

   

    if(found==1)

        cout<<"found "<<search;

    else

        cout<<"Can't found "<<search;

   

    }

getch();

}

No comments:

Post a Comment