what's lacking in this code?..

the problem is : to make this a diamond. and use only 1 printf("*");.

here is the code :


#include<stdio.h>
#include<conio.h>



main()
{
int x,y,a=6,b=5,z;

for(x=1;x<=(a*2)-1;x++)
{
if(x<=a)
z = x;
else
z = b--;

for(y=1;y<=z;y++)
{
printf("*");
}
printf("\n");

}

getch();

}

now the problem is i made only a half diamond.. what's lacking in this code?..
the only output in this is

*
**
***
****
*****
******
*****
****
***
**
*

hope you can help me. thank you.
Last edited on
closed account (zb0S216C)
Please don't double-post.
It actually made a diamond, but if i were you, i would add a 'space' to space out the '*' evenly.
it is still the same.. a half diamond..
You're not printing any spaces - how do you expect it to form a diamond?
Last edited on
Topic archived. No new replies allowed.