Microsoft Interview Question
Software Engineer / DevelopersThis problem I guess is not completely stated .Actual solution one has to avoid the floating point as putPixel(x,y) takes x and y as the integers and if we use the floor or ceiling functions (automatic coercion ) it doesn't print the circle that good .
Key is breshenham's circle drawing algorithm one can have look if wanted in wikipedia .neat and clean algo .
I did not get the above solution.
it seems to me it just print a line of * * * with space in between.
I think there should be at least some function as drawpoint(x,y)?
pls correct me if I am wrong
r - radius of circle
- Aazad December 19, 2009for every i,j check if it lies on circumference of the circle
for (i=-r;i<=r;i++){
for (j=-r;j<=r;j++){
if(round(sqrt(i*i+j*j)==r)
printf("*");
else
printf(" ");
}
}