PLease tell me y this program will not compile. I tried it and the only thing that is causing trouble is the last line…… the cout line. the program compiles when i take out the << lsposition << part but the it dosen’t display the place the integer is in.
Please Help If You Can….
Here is the code… and don’t worry about iostream or namespace, thats not the problem…
//Exercise Five Linear Search
cout << "\n\n\n…..Linear Search…..\n\n";
//Program lists numbers and asks user to enter a number. Program searches for positions number
//sets base array
int lsarray[17] = {7,3,32,2,55,34,6,13,29,22,11,9,1,5,42,39,8};////// (X)
//lists nmbers in array
cout << "List: 7, 3, 32, 2, 55, 34, 6, 13, 29, 22, 11, 9, 1, 5, 42, 39, 8";
//sets value int
int lsvalue = 0;////////// (#)
//gets value ( number searching for )
cout << "\nEnter An Integer In The List To Search For: ";
cin >> lsvalue;////////// (#)
//sets position int in a for code
for (int lsposition = 0; lsposition <= lsvalue; lsposition++)///////(I)
{
if (lsarray[lsposition] == lsvalue)
break;
else
continue;
}
cout << "\nItem Found At Index [" << lsposition << "]";
please don’t write a new code and just use what i have.
Thanks in advance
Technorati Tags: array, exercise, iostream, linear search, lt, namespace, number program, program searches, quot, thanks in advance, value int, worry