sand watch (for height 4 : 4 lines in the upper half and 4 lines in the lower):
INPUT:
4

OUTPUT:
*******
*****
***
*
*
***
*****
*******

i am not sure how to form a shape like this with C. can you help me?

I would use two for loops - one counts down from the number of asterisk and then another that counts up to the number of asterisk.

ok but all i can think of is

for(i=0;i<=num1;i++)
{
            printf("*\n");
}
for(j=num1;j<=0;j--)
{
           printf("*\n")
}

and as you see it is not a sand watch shape :'(

Well kind of...try looking into something like this

int num1 = 6, i = 0, j = 0;

	for(i = num1; i >= 0; --i)
	{
		for (j = i; j >= 0; --j)
		{
			fputc('*', stdout);
		}
		fputs("\n", stdout);
	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.