Suppose you want to print a circle for the given radius and want to use some character to draw the circle. You can use the following
#include <stdio.h>
void circle(int x, char c)
{
int i,j;
for(i=-x;i<x;i++)
{
for(j=-x;j<x;j++)
{
if((i*i+j*j)<(x*x))
printf("%c",c);
else
printf(" ");
}
printf("\n");
}
}
int main(void) {
circle(20, '*');
return 0;
}
Remember vertical alignment and horizontal are not the same so it could not look as circle but this is the algo if applied on pixcel it will look perfect. Based on the mathematical formula x^2+y^2 = r^2