Pyrimid program not working for input over 20 why not?

Jun 1, 2012 at 3:38am
So my program is working essentially but any input over 10 the program, over laps and just gets weird, maybe im doing this wrong but would like some help
int rows, star, spaces;
int number_of_stars = 6;
int number_of_rows = number_of_stars;

for (rows=1; rows <= number_of_rows; rows++) {
for (spaces=1; spaces <= number_of_stars; spaces++) {
printf(" ");
}
for (star=1; star <= rows; star++) {
printf("*");
printf(" ");
}
printf("\n");
number_of_stars = number_of_stars - 1;
}
return 0;
}




Any help would be greatly appreciated
Jun 1, 2012 at 3:44am
Looks fine up to 39 for me.
Once I get to 40 it starts to wrap because the pyramid exceeds the console width, but that is to be expected.
Topic archived. No new replies allowed.