New course! Every coder should learn Generative AI!
Try a free lesson+ 9
Simplest method:
Allocate a square matrix.
char matrix[5][5];
Fill it with stars:
for (int line = 0; line < 5; line++)
for (int colum = 0; column < 5; column++)
matrix[line][column] = '*';
Remove a line:
for (int line = 0, column = 2; line < 3; line++, column--)
matrix[line][column] = ' ';
Repeat for the other three lines of your diamond.