Tuesday, 15 December 2015

Write a program that declare an array of 10 elements and input an element n to be searched,,with sequential search

#include<iostream>
#include<conio.h>
using namespace std;
main()
{
   int arr[10]={10,20,30,40,50,60,70,80,90,100};
   int n, loc=-1;
   cout<<"Enter element to be search  ";
   cin>>n;
   for(int a=0; a<n; a++)
   {
      if(n=arr[a])
      loc=a;}
      if(loc==-1)
      cout<<" VAlue not found";
      else
      cout<<" Value found at array "<<loc;
 
   }

No comments:

Post a Comment