This program is supposed is to take the input of a odd integer and print a symmetrical diamond. The thing is, is that I've created a diamond but it isn't symmetrical. If the user enters '5' it should be five *s on the third line not six. Can give me any suggestions. I have a general understanding of nested loops as a whole nested for loops are the worse for me. Thanks in advance.
Code:
#include <stdio.h>
int main ()
{
int Height;
int x, y, z;
printf("What is the Height of the Diamond:\n");
scanf("%d", &Height);
for (x=(Height-1); x>0; --x)
{
printf("%*s",x,"");
for (y=x; y<Height; ++y)
{
for (z=(Height-1); z>y; z--)
{
printf("*");
}
}
printf("\n");
}
// Beginning of bottom half of the diamond...
for (x=(Height-1)/2; x<Height; ++x)
{
printf("%*s",x,"");
for (y=x; y<=Height; y++)
{
for (z=(Height-1); z>y; z--)
{
printf("*");
}
}
printf("\n");
}
return 0;
}