Well, I need to code a pyramid that prints the following pyramid WITHOUT the stars

*********1
********232
*******34543
******4567654
*****567898765
****67890109876
***7890123210987
**890123454321098
*90123456765432109
0123456789876543210

In the center, there are prime numbers, from 1 to 9, and after that, they cycle. (1,3,5,7,9,1,3,5,7,9 and so on).

I made the code for the pyramid and it works.

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

int main(){
int rows,star,spaces,num_row,num_star;

printf("Insert number of stars\n");
scanf("%d",&num_star);
num_row = num_star;
for (rows=1; rows <= num_row; rows++)
{
for (spaces=1; spaces <= num_star; spaces++)
{
printf(" ");
}
for (star=1; star <= rows; star++)
{
printf("*");
printf(" ");
}
printf("\n");
num_star--;
}
return 0;
}
``````

But I don't know how to implement the necessary code to print the number pyramid. The point is, it can only have a maximum of 10 lines.

Can anybody help me? I'm lost here :(

## All 2 Replies

the row number should be odd so the condition in the inner loop that prints the number should have a limit of row*2-1

for the numbers use conditions that prints out the current row and by incrementing a counter until the odd number corresponding to that row is found then decrement the counter

But I don't know how to implement the necessary code to print the number pyramid.

It's a little more complex than what you've done. I'd suggest breaking each line down into four parts: