#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
//Part I /////////////////////////////////////////////////////
char myArray_1[3]; // declare an array myArray_1 of 3 integers
myArray_1[0]= 'a'; // define myArray_1
myArray_1[1]= 'b';
myArray_1[2]= 'c';
for (int i=0; i<3; i++)
cout << myArray_1[i] << endl; // print myArray_1
cout << endl;
//Part II ////////////////////////////////////////////////////
int myArray_2[10] = {0}; // declare myArray_2 (0 as default value)
for ( i=0; i<10; i++)
myArray_2[i] = i; // define myArray_2
for (i=0; i<10; i++)
cout << myArray_2[i] << endl; // print myArray_2
cout << endl;
//Part III ///////////////////////////////////////////////////
double myArray_3[2][2]; // declare a 2 dimansional array myArray_3
double count=0;
for ( i=0; i<2; i++)
{
for (int j=0; j<2; j++)
{
count++;
myArray_3[i][j] = count * 11.1; // define myArray_3
}
}
for ( i=0; i<2; i++)
for (int j=0; j<2; j++)
cout << myArray_3[i][j] << endl; // print myArray_3
getchar(); // wait for a key to be pressed
return 0;
}
/*
This tutorial demonsterates the use of arrays.
Arrays are a series of elements (variables) of the same type placed
consecutively in memory that can be individually referenced by
adding an index to a unique name.
*/
Download Visual C++ Source Code
I hope you found this c++ tutorial useful!
Don't forget to mention Apron Tutorials in your References!