Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Recently I went to an interview for a C development position. Instead of asking me questions, they just gave me 20 code snippets to find out two logical errors on each one. I just couldn't complete all of the 20 since it took me time to go through each of these code snippets.

My question is: Is this the right way to judge a candidate? If yes, how can I improve over my error detection skills so that I don't need to waste a lot of time in the next interview? If possible, please, suggest me some links where I could find lots of samples of such questions (mainly in C).

Thanks and regards, Maddy


migration rejected from stackoverflow.com Jun 10 at 13:32

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by durron597, gnat, Ixrec, MichaelT, Kilian Foth Jun 10 at 13:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking career or education advice are off topic on Programmers. They are only meaningful to the asker and do not generate lasting value for the broader programming community. Furthermore, in most cases, any answer is going to be a subjective opinion that may not take into account all the nuances of a (your) particular circumstance." – durron597, gnat, Ixrec, MichaelT, Kilian Foth
If this question can be reworded to fit the rules in the help center, please edit the question.

Its purely dependent on interviewer how they judge their candidate. We can't do anything for that. To improve you error detection answer is as usual "Practice and more practice". To find example just google "Interview question for C" or "Practical interview question for C". –  Harry Joy Jan 10 '11 at 8:51
@Harry...I really agree with that.Now the main problem lies in the fact that these questions are just extracts of some code related to that company where we never have any idea what is it actually about.i really dont think this is the perfect way to judge any candidate within a certain time limit. –  Maddy Jan 10 '11 at 8:53
That sounds pretty absurd. If the only important thing about an applicant to that particular company is that they can identify and debug logical errors as quickly as possible, that might be a good indication of what your job will be. I'm not sure you want to work there. Debugging skills are important, but writing code without logical errors in the first place seems like a good approach, too. –  Cody Gray Jan 10 '11 at 8:54
@Maddy its normal. as for example If you are going for interview for "Java developer" then you should at least know the basic knowledge of Java coding. and company will surely give you some Java code snippet to handle to test how much you know about Java. So as per i think it is normal to ask code snippets in interview. It helps company to know how much knowledge a candidate have in which he is applying. –  Harry Joy Jan 10 '11 at 8:59
I had a similar experience (one snippet each, in 3 different languages). The code was totally out of context. But the interviewer just wanted to know how I analyse the code and figure out what it does. (Later, he, "out of curiosity" asked me whether I could say some potential tool/application where it could be used). So, I guess it happens that way at some places. (well, he had more snippets, but I think he stopped when he was happy with me, for I got the offer soon) –  ThisIsMeMoony Jan 10 '11 at 9:04

2 Answers 2

Yes, but not completely.

You should judge a candidate on technical merits, but not solely. Having them write code (or use code) during the interview is essential in my opinion, but at the same time you need to look at much more then that. Are they a good fit for the team? Do they have the experience necessary to work without instruction? Do they interact well with others?

Sorry but a clear -1. Finding errors in code snippets without context and even without a computer is a dumb thing to do. Do some brief pair programming instead. –  user8685 Jan 10 '11 at 15:14
@Developer Art: I focused on it's a good way to measure some aspects of technical merit, not as a whole interview. –  Josh K Jan 10 '11 at 15:41
Attempting to debug code without a compiler seems like a tedious, academic exercise at best. Obviously, an experienced programmer will/should be able to look at a snippet of code and see obvious logical errors, but there's as much point to requiring them to demonstrate this as there is for an engineer to do long division in a job interview. Mix in speed as a criterion, and you've got a really poor way of evaluating candidates. –  Cody Gray Jan 11 '11 at 5:55

do not discount these type of interview questions. the skill being tested in 'code comprehension' questions is the ability to do a mental dry run of the code. this skill demonstrates greater feel for the language. candidates who possess this ability will write code that works the first time, and will be able to do it faster. they will also be able to copy paste code from other projects and modify it faster.

the way to improve this skill is to read more code and try to understand what it does.

you can start with the smaller open source c libraries.

another way to improve this ability is to solve computer programming problems in at least 5 different ways.

yet another way is to ensure your code is correct before compiling and executing. to make sure you are doing all the work, either you use a simple text editor, or you turn off all the syntax highlighting/intellisense stuff while you are programming.