#include<iostream
>
#include<conio.h
>
using namespace std;
int main()
{
int n,num,flag=0,pos;
cout<<"Enter the size of array : ";
cin>>n;
int *arr=new int[n];
cout<<"Enter elements of array\n";
for(int i=0;i<
n;i++)
{
cin>>arr[i];
}
cout<<"Elements of array\n";
for(int i=0;i<
n;i++)
{
cout<<
arr[i]<<"\t"
;
}
cout<<"\nEnter element to search : ";
cin>>num;
for(int i=0;i<
n;i++)
{
if(arr[i]==num)
{
flag=1;
pos=i+1;
break;
}
}
if(flag==1)
{
cout<<num
<<" is found at "<<
pos<<
" possition.";
}
else
{
cout<<num
<<" is not found in the array list.";
}
getch();
return 0;
}
No comments:
Post a Comment