How to write a C Program to Draws a circle of radius r with points satisfying x^2+y^2 <= r^2 in C Programming Language ?
Solution For C Program :
void circle(unsigned int radius)
/* Draws a circle of radius r with points satisfying x^2+y^2 <= r^2 */
{
int r_squared = pow(radius,2);
printf("radius is: %d \n", r_squared);
for(int y = 2*radius; y >= 0; y -= 1) {
for(int x = 0; x <= 2*radius; x += 1) {
printf("(x,y) is: (%d, %d) \n", y-radius, x-radius);
if ((pow(x-radius,2) + pow(y-radius,2)) <= r_squared) {
printf("*");
} else {
printf(" ");
}
printf("\n");
}
}
}