Program to search a number using Linear Search

#include<iostream.h> main() { int n, a[20],ser,i,flag=0; count<<"Enter the size of an array:"; cin>>n; count<<"Enter the elements to array:\n"; for(i=0; i<n; i++) cin>>a[i]; cout<<"\n Enter the elents to search:"; cin>>ser; for(i=0; i<n; i++) { if(ser == a[i]) { flag = 1; break; } } if(flag == 1) cout<<"\n Element "<<ser<<"is found in the array\n"; else cout<<"\n Element "<<ser<<"is not found in the array\n"; return (0); }
[wp_ad_camp_1]
OUTPUT Enter the size of an array: 5 Enter the elements to array: 1 4 6 9 7 Enter the element to search: 9 Element 9 is found in the array ----- Enter the size of an array: 4 Enter the elements to array: 9 5 7 3 Enter the element to search: 4 Element 4 is not found in the array