Part II: 2-Dimensional Array file name: lab1part2.cpp (10 points) Write a C++ fu
ID: 3541554 • Letter: P
Question
Part II: 2-Dimensional Array
file name: lab1part2.cpp
(10 points)
Write a C++ function, named DrawN(), that will receive a two-dimensional array of chars (size 10 x 10) as a parameter and assign the character
Explanation / Answer
#include<iostream>
using namespace std;
void DrawN(char a[10][10])
{
for(int i=0; i<10; i++)
{
for(int j=0; j<10; j++)
{
if(i==j) a[i][j] = 'N';
if(j==9 || j==0) a[i][j] = 'N';
}
}
}
int main()
{
char a[10][10] = {};
for(int i=0; i<10; i++)
{
for(int j=0; j<10; j++)
{
a[i][j]= ' ';
}
}
DrawN(a);
for(int i=0; i<10; i++)
{
for(int j=0; j<10; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
return 0;
}