sequential_search_simple - cin >> key...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #include <iostream> using namespace std const int MAX_CUSTOMERS = 5 int main() { int num[MAX_CUSTOMERS] int i = 0 int key = 0 bool found = false for (i = 0 i < MAX_CUSTOMERS i++) { cout << "Enter your score: " cin >> num[i] } cout << "Enter a score that you'd like to search for: "
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cin &gt;&gt; key for (int j = 0 j &lt; MAX_CUSTOMERS j++) { if (num[j] == key) { cout &lt;&lt; &quot;Found it in position &quot; &lt;&lt; j &lt;&lt; endl found = true break } } if (found == false) { cout &lt;&lt; &quot;You didn't find it &quot; &lt;&lt; endl } return 0 }// end of main...
View Full Document

This note was uploaded on 04/01/2008 for the course CMPSC 101 taught by Professor Drobish,renee during the Spring '07 term at Pennsylvania State University, University Park.

Ask a homework question - tutors are online