Question 10 is a bad question. The host environment is under no obligation to provide you with pointers to writable memory in argv. Furthermore, this is veering off from C knowledge into C trivia.<p>Question 12 is even worse, as the processing order is implementation defined. On my compiler, it prints out 60..40..60.<p>C questions should be designed to show whether or not the candidate can write robust, professional quality code, not to test esoteric knowledge that even the interviewer can't get right.<p>I was asked questions like these in an interview once. It was such a massive red flag to me that I went with another company (the final straw was arguing over the size of int, which he insisted was always 32 bits).
<i>Well, Though the above code is not freeing up the memory allocated to ‘ptr’ but still this would not cause a memory leak as after the processing is done the program exits.</i><p>Well this is always true, so I guess that means there's no such thing as memory leaks in C. Checkmate garbage collectors.
I wonder why there are so many articles about C getting passed around where the author just doesn't know the language that well, or at the very least ventures well outside the boundaries of his knowledge. Where are the <i>good</i> articles on C, and why don't they ever show up on HN?
For those of you interested, the first stage in the SpaceX interview process, at least for the flight software group, is a series of questions like these, with A-G multiple choice answers. You had to identify the class of bug.<p>The G choice was always "No, looks good".<p>It's timed.
Here is another interesting C/Objective-C Q&A: <a href="http://www.eosgarden.com/en/articles/objc-quizz/" rel="nofollow">http://www.eosgarden.com/en/articles/objc-quizz/</a>