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

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; }

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

Find your day from your DOB?

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; }

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

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)

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

write a program in c to merge two array

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

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

how to swap 3 nos without using temporary variable

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

Categories
• C Code (421)
• C++ Code (127)
• VC++ Code (17)
• Java Code (84)
• Dot Net Code (114)
• Visual Basic Code (11)
• Programming Code AllOther (56)