We have to create a diamond that is centered on the screen using this code that creates a triangle. My thought process has been to use 4 right triangles to create the diamond. What im stuck on is trying to make the triangle increase in the opposite direction. Is this the way to go or is there a better way? thx for any advice.
#include<ctype.h>
#include<stdio.h>
#define N 33
void repeat(char, int);
int main(void)
{
char c = 'X';
int i;
for (i = 1;i <= N; i+=2) {
repeat(c, i);
putchar('\n');
}
}
void repeat(char c, int how_many)
{
int i;
for (i = 1; i <= how_many; ++i)
putchar(c);
}