nested for statements

hi, I'm new to programming and joining forums of any sort! I'm trying to teach myself through books and this site.I am trying to produce this with nested for statements;
**********
0********* 0 = blank spaces
00*******
000******
0000*****
00000****
000000***
0000000**
00000000*

I've got this so far;

#include <stdio.h>

int main()
{
int a, b, c;

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

return 0;
}

I'm nearly there, I just don't know how to get rid of my extra spaces and *s.
Think i need another loop
Thanks for any help you can give
Last edited on
don't nest the third loop inside b and it works fine

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>

int main()
{
	int a, b, c;
	
	for(a = 0; a < 10; a++)
	{
		for(c = 0; c < a; c++)
		{
			printf(" ");
		}
		for(b = 10; b > a; b--)
		{		
			printf("*");
		}
		printf("\n");
	}

	return 0;
}


and also change "b>1" to "b>a" so b+c would iterate 10 times total each time a loops
Last edited on
Thank you, always seems so simple when lead in the right direction. No doubt I will be in need of assitance at some point again.
Topic archived. No new replies allowed.