Puzzle L40


Solid Circle

[H-10]Write a function that prints a solid circle of stars.

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

Do this using a doubly nested loop that iterates through all rows and all columns. If the distance a particular row and column is from the center of the circle is less than the radius, print a star. Otherwise print a space. Use the Pythagorean theorem to calculate the distance squared. The center of the circle is at (row, col) == (radius, radius). Don't use center() for this.

#include <stdio.h>

void circle(int radius)
{
}
  
int main()
{
  circle(9);  
  	
  return 0;
}


Previous Page        Answer         Next Page         Home