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 |
Predict the Output: int main() { int *p=(int *)2000; scanf("%d",2000); printf("%d",*p); return 0; } if input is 20 ,what will be print
Write a program to model an exploding firecracker in the xy plane using a particle system
Derive expression for converting RGB color parameters to HSV values
Find your day from your DOB?
15 Answers Accenture, Microsoft,
Printf can be implemented by using __________ list.
Write a C program to print ‘Campus Force training’ without using even a single semicolon in the program.
#define int char main() { int i=65; printf("sizeof(i)=%d",sizeof(i)); }
main() { char *p = “ayqm”; printf(“%c”,++*(p++)); }
29 Answers IBM, TCS, UGC NET, Wipro,
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal.
6 Answers Fusion Systems GmbH,
int a=1; printf("%d %d %d",a++,a++,a); need o/p in 'c' and what explanation too
main() { int i = 257; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }
Finding a number multiplication of 8 with out using arithmetic operator