Read array element one by one from keyboard : array read « Array « C++ Tutorial






#include <iostream>
#include <cctype>
using std::cout;
using std::cin;
using std::endl;

int main() {
  int height[10]; 
  int count = 0;  
  char reply = 0; 

  do {
    cout << endl
         << "Enter a height as an integral number of inches: ";
    cin >> height[count++];

    // Check if another input is required
    cout << "Do you want to enter another (y or n)? ";
    cin >> reply;
  } while(count < 10 && std::tolower(reply) == 'y'); 

  return 0;
}
Enter a height as an integral number of inches: 12
Do you want to enter another (y or n)? n








4.2.array read
4.2.1.Read array element one by one from keyboard
4.2.2.Read array element from keyboard and output