Print an n-row pyramid of *: row i has n - i spaces first, then 2i - 1 stars, with no space after the stars. For n = 3, the rows are 2 spaces and 1 star, 1 space and 3 stars, 0 spaces and 5 stars. Finish pyramid(n); the program prints one with n = 3 and one with n = 5.
*
***
*****
*
***
*****
*******
*********#include <stdio.h>
void pyramid(int n) {
for (int i = 1; i <= n; i++) {
// your code here: print the spaces at the start of this row
// your code here: print the stars of this row
printf("\n");
}
}
int main(void) {
pyramid(3);
pyramid(5);
return 0;
}
Run tries the examples. When they look right, Submit.