/* Print a 3 x 3 grid of letters from a
multidimensional matrix. Output will
be:
A B C
D E F
G H I
*/
#include<iostream>
using namespace std;
int main()
{
// Declare 3x3 grid of letters
char letters[3][3];
// Fill letters in the grid,
// from A to F
char current_letter='A'; // First letter will be 'A'
int row=0;
while(row<3) // loop through the rows of the grid
{
int column=0;
while(column<3) // loop through the columns of the grid
{
// Insert letter into current grid location
letters[row][column] = current_letter;
// Prepare to transition to next grid location
column++;
current_letter = current_letter+1; // 'A'+1 -> 'B'
// 'B'+1 -> 'C', etc
}
row++;
}
// Print out grid of letters
row=0;
while(row<3)
{
int column=0;
while(column<3)
{
cout << letters[row][column] << "\t";
column++;
}
// Print new line before starting next column
cout << endl;
row++;
}
return 0;
}