DS2_1

//Sequential Search (Linear Search) //BCA Support //www.bcasupport.xyz #include <iostream.h> #include <conio.h> int num[10],a,no,flag=0; void search(); void main() { clrscr(); cout<<"\nEnter 10 numbers :\n"; for(a=0;a<10;a++) cin>>num[a]; cout<<"\nEnter number to search : "; cin>>no; search(); getch(); } void search() { for(a=0;a<10;a++) { if(num[a]==no) cout<<endl<<no<<" found on position "<<a+1; else flag++; } if(flag==10) cout<<"\nNumber not found!"; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.