technical interview Q & A for high-tech professionals
Interview Questions
Electronics Hardware
Computer Software
Quick Thinking Tests
General questions
Phone screening questions
Submit your Q or A

Technical articles
Technical discussion
Resume and interview
How to get a job in Silicon Valley
How much are you worth on market?
Why you may need an agent

Break point
Written Exam
Logic Tests
Professional Test
Tomato company
Cup of coffee
How stock market works
Engineering jokes

About Hitequest
About Hitequest
Home page


=Computer Software Questions=


N.J. is using the following questions to interview embedded systems C programmers:
1. What is the purpose of the preprocessor directive #error?
2. How do you code an infinite loop in C ?
3. What are the uses of the keyword static?
4. What does the following code output?
void foo(void)
unsigned int a=6;
int b=-20;
(a+b >6) ? puts(">6") : puts("<=6");


1. Either you know the answer to this, or you don't. This question is useful to tell how deep a candidate dives into textbooks.
2. My preferred solution is:

Many programmers seem to prefer:
for(; ;)

This construct puzzles me because the syntax doesn't exactly spell out what's going on. Thus, if a candidate gives this as a solution, I'll use it as an opportunity to explore their rationale for doing so.

A third solution is to use a goto:
goto Loop;

Candidates who use this are either assembly language programmers (which is probably good), or else they are not programmers looking to get into a new field.
  3. This simple question is rarely answered completely. Static has three distinct uses in C:
A variable declared static within the body of a function maintains its value between function invocations.
A variable declared static within a module, (but outside the body of a function) is accessible by all functions within that module. It is not accessible from other modules. That is, it is a localized global.
Functions declared static within a module may only be called by other functions within that module. That is, the scope of the function is localized to the module within which it is declared.
Most candidates get the first part correct.A reasonable number get the second part correct, while a pitiful number understand the third answer. This is a serious weakness in a candidate, since he obviously doesn't understand the importance and benefits of localizing the scope of both data and code.
  4. The question tests whether you understand the integer promotions rules in C - an area that I find is very poorly understood by many developers.
Anyway, the answer is that this outputs ">6". The reason for this is that expressions involving signed and unsigned types have all operands promoted to unsigned types.
Thus -20 becomes a very large positive integer and the expression evaluates to greater than 6. This is a very important point in embedded systems where unsigned data types should be used frequently.
If you get this one wrong, you are perilously close to not getting the job.