cs509:arrayfromkeyboard
Array example from class, 3/6/13
/*
Write a program that will fill an array a with 20 values of type int read in
from the keyboard.
*/
#include <iostream>
using namespace std;
int main()
{
// array size in a constant
const int asize = 20;
// declare array
int a[ asize ] = { 0 };
// loop to get 20 values from keyboard and fill array
for ( int i = 0; i < asize; i++ ) {
cout << "\n Enter value for array element " << i << ": ";
cin >> a[ i ];
}
}
cs509/arrayfromkeyboard.txt · Last modified: by jchung
