sa2209GitHub
5/22/2016 - 9:11 PM

arrays.cpp

// Lesson 13
// Introduction to Arrays

#include <iostream>
#include <iomanip>

using namespace std;

class MyArray {

public:
    int x;
    int y;
    int z;
};

int main() {

    int arry[10];

    for (int i = 0; i < sizeof(arry) / sizeof(int); i++) {
        arry[i] = i;
    }

    for (int i = 0; i < sizeof(arry) / sizeof(int); i++) {
        cout << arry[i] << endl;
    }
    cout << endl;

    MyArray marry[100];

    for (int i = 0; i < sizeof(marry) / sizeof(marry[0]); i++) {
        marry[i].x = i;
        marry[i].y = i * 8;
        marry[i].z = i * 16;
    }
    for (int i = 0; i < sizeof(marry) / sizeof(marry[0]); i++) {
        cout << setw(2) << marry[i].x << setw(8) << marry[i].y << setw(8) << marry[i].z << endl;
    }

    return 0;
}