Write prgm to store the Element in 1 d array and perform operation like searching and traversing
#include<iostream.h> #include<conio.h> void main(); { int arr[10],search_ele,n,i,flag=-1; char ch; clrscr(); cout<"enter the size of array: "; cin>>n; cout<<"enter the element in array: "<<endl; for(i=0;i<n;i++) { cin>>arr[i]; } cout<<"\nenter 's' for searching element in array: "; cout<<"\nenter 't' for traversing element of array: "<<endl; cin>>ch; switch(ch) { case 's': cout<<"\nenter element to be seach: "; cin>>search_ele; for(i=0;i<n;i++) { if(arr[i]==search_ele) { flag=1; break; } else { flag=-1; } } if(flag==1) { cout<<"element "<<search_ele<<"found at index"<<i<<endl; } else { cout<<"element is not found in an array!"<<endl; break; } case 't': cout<<"\nTraverse of an array:"<<endl; for(i=0;i<n;i++) { cout<<"arr["<<i<<"]="<<arr[i]<<endl; } } getch(); }