Microsoft Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

r - radius of circle
for every i,j check if it lies on circumference of the circle

for (i=-r;i<=r;i++){
for (j=-r;j<=r;j++){
if(round(sqrt(i*i+j*j)==r)
printf("*");
else
printf(" ");
}
}

- Aazad December 19, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Need to add printf("\n"); after the inner for loop. Otherwise all * would be printed in one line.

- Mukesh January 30, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

//theta increments may b fine tuned for better look
for(theta = 0; theta <360; theta++)
{
x = r*cos(theta);
y = r*sin(theta);
}
//better than checking all i,j s in the plane.

But I doubt if thats the expected answer.

- anon December 21, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This problem I guess is not completely stated .Actual solution one has to avoid the floating point as putPixel(x,y) takes x and y as the integers and if we use the floor or ceiling functions (automatic coercion ) it doesn't print the circle that good .

Key is breshenham's circle drawing algorithm one can have look if wanted in wikipedia .neat and clean algo .

- C.G.I December 21, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I did not get the above solution.
it seems to me it just print a line of * * * with space in between.
I think there should be at least some function as drawpoint(x,y)?
pls correct me if I am wrong

- newlifeseattle December 22, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Function DrawCircle (r, colour)
x ← 0, y ← r, d ← 1 − r
CirclePoints (x, y, colour)
While (x < y)
if (d < 0) // East
d ← d + 2 ∗ x + 3, x ← x + 1
else // South-East
d ← d + 2 ∗ (x − y) + 5, x ← x + 1, y ← y − 1
CirclePoints (x, y, colour)
EndWhile
EndFunction

- Anonymous January 12, 2010 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More