ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Code Snippets  >>  Programming Code  >>  C Code
 
 


 

 
 C Code interview questions  C Code Interview Questions
 C++ Code interview questions  C++ Code Interview Questions
 VC++ Code interview questions  VC++ Code Interview Questions
 Java Code interview questions  Java Code Interview Questions
 Dot Net Code interview questions  Dot Net Code Interview Questions
 Visual Basic Code interview questions  Visual Basic Code Interview Questions
 Programming Code AllOther interview questions  Programming Code AllOther Interview Questions
Question
Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2)
without making use of any floating point computations at all.
 Question Submitted By :: =-PKG-=
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.
Answer
# 1
#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 ?    8 Yes 18 No
Vignesh
 
  Re: Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.
Answer
# 2
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 ?    11 Yes 10 No
Daru
 
 
 

 
 
 
Other C Code Interview Questions
 
  Question Asked @ Answers
 
main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }  1
main() { clrscr(); } clrscr();  1
main() { extern i; printf("%d\n",i); { int i=20; printf("%d\n",i); } }  1
main() { int i=-1; +i; printf("i = %d, +i = %d \n",i,+i); }  1
main() { int i, n; char *x = “girl”; n = strlen(x); *x = x[n]; for(i=0; i<n; ++i) { printf(“%s\n”,x); x++; } }  1
main() { struct student { char name[30]; struct date dob; }stud; struct date { int day,month,year; }; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month, &student.dob.year); }  1
programming in c lanugaue programm will errror error with two header file one as stdio.h and other one is conio.h  1
union u { struct st { int i : 4; int j : 4; int k : 4; int l; }st; int i; }u; main() { u.i = 100; printf("%d, %d, %d",u.i, u.st.i, u.st.l); } a. 4, 4, 0 b. 0, 0, 0 c. 100, 4, 0 d. 40, 4, 0 HCL1
void pascal f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } void cdecl f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } main() { int i=10; f(i++,i++,i++); printf(" %d\n",i); i=10; f(i++,i++,i++); printf(" %d",i); }  1
write a program to Insert in a sorted list Microsoft4
main() { signed int bit=512, mBit; { mBit = ~bit; bit = bit & ~bit ; printf("%d %d", bit, mBit); } } a. 0, 0 b. 0, 513 c. 512, 0 d. 0, -513 HCL1
How to access command-line arguments?  4
main() { int i, j; scanf("%d %d"+scanf("%d %d", &i, &j)); printf("%d %d", i, j); } a. Runtime error. b. 0, 0 c. Compile error d. the first two values entered by the user HCL1
main() { char c; int i = 456; clrscr(); c = i; printf("%d", c); } a. 456 b. -456 c. random number d. none of the above HCL1
plz send me all data structure related programs  1
main() { int i=0; for(;i++;printf("%d",i)) ; printf("%d",i); }  1
Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. Microsoft15
int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }  1
main() { int i; float *pf; pf = (float *)&i; *pf = 100.00; printf("\n %d", i); } a. Runtime error. b. 100 c. Some Integer not 100 d. None of the above HCL1
String reverse with time complexity of n/2 with out using temporary variable. NetApp8
 
For more C Code Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com