Puzzle L19


Print a wedge of stars, with the diagonal on the left

[M-8]Write a main() program that prints a wedge of stars. Print n stars in row 0, (n-1) stars in row 1, (n-2) stars in row 2, and so on. But now, pad the left side of each line with spaces so that each line consists of n characters. Here is what this looks like:

***************
 **************
  *************
   ************
    ***********
     **********
      *********
       ********
        *******
         ******
          *****
           ****
            ***
             **
              *

You will need two loops nested inside of the outer loop.

Here is a skeleton:


#include <stdio.h>
#include <stdlib.h>

/* Puzzle L19 -- print wedge of stars, n stars in the first row
|
|  Print n characters per row, however row k starts with k
|  spaces, with the remaining characters stars.
*/
int main()
{
  int row, col;
  int n=15 ;
  
  for (   )
  {
    for (   )
      printf(" ");
    for (   )
      printf("*");
    printf("\n");
  }
  
  
  return 0;
}



Previous Page        Answer         Next Page         Home