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..

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..

#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

Write a program that find and print how many odd numbers in a binary tree

main() { float i=1.5; switch(i) { case 1: printf("1"); case 2: printf("2"); default : printf("0"); } }

void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }

main() { static int a[3][3]={1,2,3,4,5,6,7,8,9}; int i,j; static *p[]={a,a+1,a+2}; for(i=0;i<3;i++) { for(j=0;j<3;j++) printf("%d\t%d\t%d\t%d\n",*(*(p+i)+j), *(*(j+p)+i),*(*(i+p)+j),*(*(p+j)+i)); } }

main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }

How do I write a program to print proper subset of given string . Eg :input: abc output:{},{a},{b},{c},{a,b},{a,c},{b,c}, {a,b,c}.I desperately need this program please mail me to saravana6m@gmail.com

main() { extern out; printf("%d", out); } int out=100;

main() { char * strA; char * strB = I am OK; memcpy( strA, strB, 6); } a. Runtime error. b. I am OK c. Compile error d. I am O

#define DIM( array, type) sizeof(array)/sizeof(type) main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr, int)); }

Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.

I need your help, i need a Turbo C code for this problem.. hope u'll help me guys.? Your program will have a 3x3 array. The user will input the sum of each row and each column. Then the user will input 3 values and store them anywhere, or any location or index, temporarily in the array. Your program will supply the remaining six (6) values and determine the exact location of each value in the array. Example: Input: Sum of row 1: 6 Sum of row 2: 15 Sum of row 3: 24 Sum of column 1: 12 Sum of column 2: 15 Sum of column 3: 18 Value 1: 3 Value 2: 5 Value 3: 6 Output: Sum of Row 1 2 3 6 4 5 6 15 7 8 9 24 Sum of Column 12 15 18 Note: Your program will not necessary sort the walues in the array Thanks..

Derive expression for converting RGB color parameters to HSV values

Categories