Prepare a c++ program of the two-dimensional array of the sample run below:
Sample Run:
[0] [1] [2] [3] [4] [5]
[0]
[1]
[2]
[3]
[4]
[5] 9.5
[6]
[7]
[8]
[9]
[10]
[11]
#include <iostream>
using namespace std;
int main() {
for (int i = 0; i <= 11; i++) {
if (i == 0) {
cout << "\t";
for (int j = 0; j <= 5; j++)
cout << "[" << j << "] ";
} else if (i == 5) {
cout << "[5] 9.5";
} else {
cout << "[" << i << "]";
}
cout << endl;
}
}
Comments
Leave a comment