Microsoft Interview Question for Interns


Country: United States
Interview Type: In-Person




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

Something like this?
#include <unistd.h>

int main(void)
{
const char hello[] = "Hello World!\n";
const size_t hello_size = sizeof(hello);
ssize_t ret;
asm volatile
(
"movl $1, %%eax\n\t"
"movl $1, %%edi\n\t"
"movq %1, %%rsi\n\t"
"movl %2, %%edx\n\t"
"syscall"
: "=a"(ret)
: "g"(hello), "g"(hello_size)
: "%rdi", "%rsi", "%rdx", "%rcx", "%r11"
);
return 0;
}

- Here we go Mario March 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

basically, it's just
print(int x)
{
int i, j;
stack<int> s;
for(; i != 0; )
{
r = x/10
i = i mod 10;
s.push(r);
}
for(char c = ' '; !s.isEmpty(); ){
c = integer to character(s.pop());
print(c);
}
}
This was the direction that he directed me.

At first, I was thinking of bits because I was quite taken aback of the question since it was like asking, write a text editor without using a text editor you know. It was the first interview!!!! Anyways, I didn't ask about system calls and such because he mentioned during the interview writing it in python because he wanted to introduce his programming language lisp to me. Just a word of advice, don't expect that you'll know the topic. If you are interested in compilers, just make sure to be clear that you are interested in it, not actually started implementing it in your room or something!

- J March 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

however, negative integers should not be ignored.

- wangxuyang March 04, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Could you provide some context? How low level should it be? Is it possible to use putc or it has to be a system call?

- superduper March 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

By using the outputstream(or)dataoutputstream we direct o/p to VDU

- Anonymous March 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can you use the stdout fd?

- fdawg4l March 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In linux you can use system call.
write(1, "hello world\n", 4);
or else
try using recursion

- divya bharathi March 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Thanks for answering guys. I seriously didn't know how to approach the problem cause it wasn't the classical interview question I was used to, aka - data structures, sorting, complexity, etc... I didn't think that if I were to talk a little bit about my side research on compilers and program analysis that I'm just beginning, he would then throw me a compilers question <WTF>. Be clear about your strengths and what you've actually done so that they expect to give you a question that will show your full capabilities.
But at least I got to talk to my interviewee about compilers and reminisce about his college life even though, I couldn't understand what he was asking me.

- J March 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hey . guyz i have a new idea. cant i copy and pest the exact body of printf function from the stdio.h . i have seen it works fine ;)

- shamikmitra1993 March 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

And i have a question ..how the in-built functions work? is their any system call made implicitly when we call this functions

- shamikmitra1993 March 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

lets say. our print method takes a byte and uses character map to print character corresponding to given byte. Now, we can represent 0-9 digit easily in byte an their corresponding character will be '0','1'...'9'.
So. if can covert given integer to array of digit and send each digit to print method. we can print that digit
without using inbuilt print method.

- Arpit March 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

how wud it be if we can use an inline assembler
i mean....
void main()
{
int i=10;
_asm
{
lea dx,i
mov ah,09h
int 21h
}
}

- hmm July 19, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

%%

Pass this through flex. Will print what you type

- Joker May 17, 2016 | Flag Reply


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