Write a C program that defines the 5 times 5 grid shown belo
Write a C++ program that defines the 5 times 5 grid shown below. The program should then call a method to display the grid. The output should look like this: char board[5][5] =
Solution
#include <iostream>
using namespace std;
void display(char board[][5])
{
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
cout<<board[i][j]<<\' \';
}
cout<<endl;
}
}
int main()
{
char board[5][5] = {{\'.\',\'.\',\'.\',\'.\',\'.\'},
{\'.\',\'*\',\'*\',\'*\',\'.\'},
{\'*\',\'*\',\'*\',\'.\',\'.\'},
{\'.\',\'.\',\'.\',\'.\',\'.\'},
{\'.\',\'.\',\'.\',\'.\',\'.\'}};
display(board);
return 0;
}
