1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
// This is array 1.
int main()
{
const int array_size = 10;
int array1[array_size] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
cout << "Display array: " << endl;
for (int i=0; i <array_size; i++)
{
cout << i << "\t" << array1[i] <<endl;
}
// This is the second
int sum = 0;
int average = 0;
int array2[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
for (int i=0; i<10; i++)
{
sum += array2 [i];
}
average = sum/10;
cout << "The average is: " << average;
system("PAUSE")
return 0;
|