Senin, 15 Desember 2025

listing4.3.cpp Accessing Elements in a Multidimensional Array

//listing4.3.cpp
#include <iostream>
using namespace std;

int main()
{
    int threeRowsThreeColumns[3][3]=\
    {{-501,205,2016},{989,101,206},{303,456,596}
    };

    cout << "Row 0: " << threeRowsThreeColumns[0][0] << " " \
        << threeRowsThreeColumns[0][1] << " " \
        << threeRowsThreeColumns[0][2] << endl;

    cout << "Row 1: " << threeRowsThreeColumns[1][0] << " " \
        << threeRowsThreeColumns[1][1] << " " \
        << threeRowsThreeColumns[1][2] << endl;

    cout << "Row 2: " << threeRowsThreeColumns[2][0] << " " \
        << threeRowsThreeColumns[2][1] << " " \
        << threeRowsThreeColumns[2][2] << endl;

    return 0;
}

output:
 
Row 0: -501 205 2016
Row 1: 989 101 206
Row 2: 303 456 596

Process returned 0 (0x0)   execution time : 0.433 s
Press any key to continue.

Tidak ada komentar:

Posting Komentar