C++ examples for Data Type:Array
Initializing an array in a declaration.
#include <iostream> #include <iomanip> using namespace std; int main() /*from w ww .j a v a 2 s .com*/ { // use initializer list to initialize array n int n[ 10 ] = { 2, 7, 4, 8, 5, 4, 0, 7, 60, 37 }; cout << "Element" << setw( 13 ) << "Value" << endl; // output each array element's value for ( int i = 0; i < 10; ++i ) cout << setw( 7 ) << i << setw( 13 ) << n[ i ] << endl; }