Well, i cant figure how print to the spaces before the *, this is how it is suppose to look:
*
***
*****
*******
EDIT: dunno how to get it to work but it should be a pascal triangle
and this is what i get
*
***
*****
*******

heres the code:

``````#include<stdio.h>
void main ()
{
int a, b, c;
printf ("Enter the number: ");
scanf ("%d", &a);

for (b=1; b<=a; b++)
{
for (c=1; c<=(b*2-1); c++)
{
printf ("*");
}
printf ("\n");
}

return;
}``````

Edited by Unidennn: n/a

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by phpbeginners
``````void main ()
{
int a, b, c;
printf ("Enter the number: ");
scanf ("%d", &a);
for (b=1; b<=a; b++)
{
for(c = a-b; c>0; c--)
{
printf(" ");
}
for (c=1; c<=(b*2-1); c++)
{
printf ("*");
}
printf ("\n");
}
}``````

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

Please don't just give away solutions, help the poster approach the problem

start quote:

``````void main ()
{
int a, b, c;
printf ("Enter the number: ");
scanf ("%d", &a);
for (b=1; b<=a; b++)
{
for(c = a-b; c>0; c--)
{
printf(" ");
}
for (c=1; c<=(b*2-1); c++)
{
printf ("*");
}
printf ("\n");
}
}
``````

end quote.

thanks for the help :)

Edited by mike_2000_17: Fixed formatting

is this what you mean?

``````#include <stdio.h>

int x,y;

main()
{
for ( x = 0; x < 10; x++, printf( "\n" ) )

for ( y = 0; y < (x*2-1); y++ )

printf( "X" );

return 0;
}``````