Sunday, 1 February 2015

Program to implement Linear search in C++

//Program to implement Linear search in C++.

#include<iostream.h>
#include<conio.h>
void main()
{
int arr[10],i,no,found=0;
clrscr();
cout<<"Enter 10 values \n";
for(i=0;i<10;i++)
cin>>arr[i];
cout<<"Enter values to find: ";
cin>>no;
i=0;
while(!found && i<10)
{
 if(arr[i]==no)
found=1;
 else
i++;
}
if(found)
cout<<"Values found on "<<i<<" index";
else
cout<<"Value not found";
getch();
}

No comments:

Post a Comment

Read contacts in iOS using Swift with error handling

Just copy and paste the below code Pre-step before pasting the below code Add below line in AppDelegate.swift file below import statement ...