C++ examples for Language Basics:Console
Read user input and store it into an array
#include <iostream> using namespace std; int main()//from w w w . java 2 s.c o m { 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; }