#include<iostream> using namespace std; int array1[5]; int i, search; bool found= false; void main () { cout<<"Enter the five elements of an integer array \n"; for (i=0 ; i<5 ; i++) { cin>>array1[i]; } cout<<endl<<"Your integer array is:"<<endl; for (i=0 ; i<5 ; i++) { cout<<array1[i]; cout<<"\t"; } cout<<endl<<endl; cout<<"Enter a number to search for: \n"; cin>>search; for (i=0 ; i<5 ; i++) { if (search==array1[i]) { cout << "The number " << search << " was found and its index is " << i << endl; found= true; break; } } if (!found) cout << "The number " << search << " was not found!! " << endl; }
main
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)