C++ Program to depict the process of linear search
#include<iostream.h>
#include<process.h>
#include<conio.h>
main()
{
clrscr();
int num[10],m;
cout<<"Enter any ten numbers as elements of an array"<<endl;
for (int i=0;i<10;i++)
{
cin>>num[i];
}
cout<<endl<<"Enter any number ";
cin>>m;
cout<<endl;
for (int j=0;j<10;j++)
{
if (num[j] == m)
{cout<<m<<" is present in the array"<<endl;
getch();
exit(0);}
}
getch();
return 0;
}
0 comments:
Post a Comment