
November 15th, 2004, 06:24 AM
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Array Table Help (Newbie)
Ok this is the example I foudn to help me understand Arrays (below).My problem is I want an array that will -when entering a number e.g. 1 would display hello, 1.5 would display bye2 would display sorry?2.4 would display (anything) How would I achieve this?#include <iostream>using namespace std;int main(){ // Declare the members of the array int Numbers[] = {8, 25, 36, 44, 52, 60, 75, 89}; int Find; int i, m = 8; cout << "Enter a number to search: "; cin >> Find; for (i = 0; (i < m) && (Numbers[i] != Find); ++i) continue; // Find whether the number typed is a member of the array if (i == m) cout << Find << " is not in the list" << endl; else cout << Find << " is the " << i + 1 << "th element in the list" << endl; return 0;}
|