C++ Array Read user input and store it into an array
#include <iostream> using namespace std; int main()/*from ww w .ja v a 2 s. com*/ { const int MAXTEMPS = 5; int i, temp[MAXTEMPS]; for (i = 0; i < MAXTEMPS; i++) // Enter the temperatures { cout << "Enter a temperature: "; cin >> temp[i]; } cout << endl; for (i = 0; i < MAXTEMPS; i++) // Print the temperatures cout << "temperature " << i << " is " << temp[i] << endl; return 0; }