Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2)
without making use of any floating point computations at all.




Answers were Sorted based on User's Feedback



Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating poin..

Answer / daru

just use Bresenham's algo

d=1-r;
y=r;
x=0;
while(y>x)
{
if(d<0)
d+=2*x+3;
else {
d+=2*(x-y)+5;
y--;
}
x++;
plotpoints(x,y);
}

Is This Answer Correct ?    33 Yes 25 No

Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating poin..

Answer / vignesh

#include<stdio.h>
#include<graphics.h>
main()
{
int x,y,r;
printf("Enter x,y,r\n");
scanf("%d %d %d",&x,&y,&r);

int g=DETECT,gmode;
initgraphics(&g,&gmode,"");
circle(x,y,r);
closegraphics();
}

Is This Answer Correct ?    19 Yes 60 No

Post New Answer




More C Code Interview Questions

main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }

1 Answers  


how can i cast a char type array to an int type array

2 Answers  


Find your day from your DOB?

15 Answers   Accenture, Microsoft,


What is the subtle error in the following code segment? void fun(int n, int arr[]) { int *p=0; int i=0; while(i++<n) p = &arr[i]; *p = 0; }

1 Answers  


What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql

0 Answers  






Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list)

3 Answers   Disney, Google, ZS Associates,


void main() { int const * p=5; printf("%d",++(*p)); }

3 Answers   Infosys, State Bank Of India SBI, Made Easy,


write a program in c to merge two array

2 Answers  


main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }

2 Answers   IBM,


Display the time of the system and display the right time of the other country

1 Answers  


how to swap 3 nos without using temporary variable

4 Answers   Satyam,


#include <stdio.h> main() { char * str = "hello"; char * ptr = str; char least = 127; while (*ptr++) least = (*ptr<least ) ?*ptr :least; printf("%d",least); }

1 Answers  






Categories