J
BAN USER- 0of 0 votes
AnswersImplement print function given an integer without using the built-in print function
- J in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Compiler
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!
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.
- J March 01, 2013But 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.