0

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
7 Years
Discussion Span
Last Post by phpbeginners
-1
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).

Votes + Comments
Please don't just give away solutions, help the poster approach the problem
0

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

-3

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;
 }
Votes + Comments
Man, 185 posts and you're still giving away homework solutions? Get it together, man!
Did you read the comments on the other post?
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.