using a for loop structure and an array write a program so t

using a for loop structure and an array, write a program so that the output consisits of six lines, with each line containing six characters. In the first line, i is 0, so all the charactes are *\'s. in the last line, i is 5, so all the characters are *\'s. in each of the four lines in the middle, one of the charactes is a* and the rest are periods.

Solution

Here as given there is an two dimensional array which needs to have * in first and last row and all other rows will have char value(i am inserting a) and one of the middle element should have * ( i am putting that at index 2)

#include <iostream>

using namespace std;

int main()
{ char a[6][6];

for(int i=0;i<6;i++)
{ for(int j=0;j<6;j++)
{ if(i==0 || i==5)
{
a[i][j]= \'*\';
}
else
{
if(j==3)
{a[i][j]= \'*\';}
else
{a[i][j] = \'a\' ;}
}
}
}

for(int i =0;i<6;i++)
{
for(int j=0;j<6;j++)
{
cout<<a[i][j];
}
cout<<endl;
}
return 0;
}

using a for loop structure and an array, write a program so that the output consisits of six lines, with each line containing six characters. In the first line,

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site