the code above is only suited for the output you wanted to have in your post.
the code in this post is more flexible. Pwede nimo ma-input ang size sa middle na line.
meaning, if you want an output like the one you placed in your post, just enter 6.
try out different numbers for different sizes. ^^
made this just for fun. hehe. ^^
Code:
#include<stdio.h>
#include<conio.h>
main()
{
int x,y,a,b,z;
printf("Enter a number: ");
scanf("%d", &a);
b = a - 1;
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();
}