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 ?    34 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 62 No

Post New Answer

More C Code Interview Questions

Write a procedure to implement highlight as a blinking operation

2 Answers  


main() { int (*functable[2])(char *format, ...) ={printf, scanf}; int i = 100; (*functable[0])("%d", i); (*functable[1])("%d", i); (*functable[1])("%d", i); (*functable[0])("%d", &i); } a. 100, Runtime error. b. 100, Random number, Random number, Random number. c. Compile error d. 100, Random number

1 Answers   HCL, rsystems,


main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; printf("\n%d %d %d",a,*f1,*f2); }

6 Answers  


main() { int *j; { int i=10; j=&i; } printf("%d",*j); }

9 Answers   HCL, Wipro,


How to count a sum, when the numbers are read from stdin and stored into a structure?

1 Answers  






Cau u say the output....?

1 Answers  


What is full form of PEPSI

0 Answers  


main() { int y; scanf("%d",&y); // input given is 2000 if( (y%4==0 && y%100 != 0) || y%100 == 0 ) printf("%d is a leap year"); else printf("%d is not a leap year"); }

1 Answers  


main() { int i=0; for(;i++;printf("%d",i)) ; printf("%d",i); }

1 Answers   Zoho,


main() { clrscr(); } clrscr();

2 Answers  


given integer number,write a program that displays the number as follows: First line :all digits second line : all except the first digit . . . . Last line : the last digit

8 Answers  


main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); }

1 Answers  


Categories