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
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 |
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 |
Link list in reverse order.
main( ) { char *q; int j; for (j=0; j<3; j++) scanf(“%s” ,(q+j)); for (j=0; j<3; j++) printf(“%c” ,*(q+j)); for (j=0; j<3; j++) printf(“%s” ,(q+j)); }
programming in c lanugaue programm will errror error with two header file one as stdio.h and other one is conio.h
write the function. if all the character in string B appear in string A, return true, otherwise return false.
Derive expression for converting RGB color parameters to HSV values
abcdedcba abc cba ab ba a a
Under linux environment can u please provide a c code for computing sum of series 1-2+3-4+5......n terms and -1+2-3+4-5...n terms..
Is the following code legal? typedef struct a { int x; aType *b; }aType
int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().
What are the following notations of defining functions known as? i. int abc(int a,float b) { /* some code */ } ii. int abc(a,b) int a; float b; { /* some code*/ }
What is the hidden bug with the following statement? assert(val++ != 0);
writte a c-programm to display smill paces