The Database Managers, Inc.

Contact The Database Managers, Inc.

Use an RSS enabled news reader to read these articles.Use an RSS enabled news reader to read these articles.

Answers to Unfair C++ Job Interview Questions

by Curtis Krauskopf

Preparing for unfair questions will also prepare you for the toughest 'fair' questions. In both cases, just remain calm, think about your answer and then proceed. Whatever you do, don't argue with the interviewer or complain that the question is unfair.

If it's a legally unfair question (a question that should not be asked during an interview), then proceed using your best judgment. An article on that is no longer available provided several provided several techniques for dodging a question without being antagonistic:

In the United States...

[t]here are several questions that employers may not legally ask applicants. Federal law attempts to ensure that candidates are hired on job qualifications and not by prejudicial criteria. Questions structured to obtain information on race, gender, religion, marital status, age, physical and/or mental status, ethnic background, country of origin, sexual preference, or any other discriminatory factor are generally illegal as grounds for making employment decisions. With few exceptions, these factors contribute nothing to your ability to perform a job, and an employer must substantiate those cases where a direct relationship is thought to exist. Anything that is not a bona fide occupational qualification may not be covered directly, although the interviewer may seek the information indirectly.

Most unfair questions that are not illegal do not have a specific right answer. Many of them depend on your people-skills and being able to read the situation. Consider the situation the same as if you were working a trade-show booth and a potential customer came up to you and asked you a loaded or unfair question. How would you turn that situation around to be a positive for your company and for yourself?

I personally know one person who was given exactly that kind of situation at a trade show. Unbeknownst to my coworker, his company's president was within earshot of the entire exchange. Within two months, my coworker was promoted to a much higher position within the company. Part of the promotion was due to hard work, but part of it was undoubtedly due to the way he handled the customer that had a problem. The other lesson in this example is that you're always interviewing for your next position. Practicing your people-skills will set you apart from the workers who just write code all day long.

Q1) The interviewer looks up from his newspaper, tosses a pencil at you and says, "Sell me this pencil". The interviewer immediately returns to reading his newspaper.

A1) You might be able to relate to this question if you've ever had to sell a programming idea to a negative audience or had to get your boss' attention on an important matter when she seemed distracted. Remember that there is no right answer so whatever you do, other than complain, is an acceptable answer.

Depending on your personality, you might take a passive approach and simply toss the pencil back to the interviewer and say, "Here, you just bought it". A more aggressive responder would yank the newspaper from the interviewer and go into a sales pitch that starts with "You need this pencil because...". If you have the interviewer's phone number in your cell phone, you could call the interviewer and start selling them the pencil when they answer the phone. Do whatever suits your personality best - this way, you will feel the most comfortable while answering the question.

Q2) The interviewer hands you a black pen and says nothing but "This pen is red."

A2) Remember the interviewer I had that thought Java and JavaScript were the same thing? This is almost the same type of question but in my case, the interviewer was seriously ignorant. When I looked at his coworkers to get a read of whether he was trying to trick me or not, they were so embarrassed that they looked like they wanted to crawl under the table.

For the red pen problem, I would write on a piece of paper to see if the ink was black or red even though the outer shell was black. You never know -- he might have installed the ink reservoir from a red pen. If the ink was red, I would agree with him. If it was black, I would show him the proof on the paper.

Q3) Write a program whose output is its own source code.

A3) A program whose output is its own source is called a quine. Some people think those kinds of programs are interesting. The techniques involved in making a quine have applications in compiler, decompiler, and encryption technologies.

Depending on the mood of the interviewer, you could initially try:

cout << "its own source code";

which the interviewer would have to admit does answer the question. A solution that is closer to the spirit of the question is in Listing L.

The interviewer might insist on a self-contained solution that doesn't use external files or resources. I found one on the Internet that is only four lines of code.


int main(int, char**) {
  FILE *fp;
  fp = fopen("myself.cpp","r");
  char buffer[80];
  while (fgets(buffer,sizeof(buffer),fp)) {
    cout << buffer;
  return 0;
Listing L: A program whose output is its own source code.

Q4) Tell me the funniest programming joke you've ever heard.

A4) For this unfair question, there's obviously no right answer and the interviewer is just seeing how well you can think "on-your-feet". If you can't think of a joke, you can just make one up on the spot. You can make your own variation of a classic joke ("Three programmers walk into a bar...") or tell about a time when something humorous happened at work. You could resite your favorite xkcd cartoon.

Whatever your response, remember to have fun with the unfair questions. If the question is clearly unfair, and the interviewer just wants to see how you respond to a situation, then go along with the situation. You can decide later if you want to work for the company based on the kinds of interview questions that were asked.

Back to the Beginning

Jump to Questions Page:  1  2  3  4  5  6  7  8  9  10  11  12  13 
Jump to Answers Page:  1  2  3  4  5  6  7  8  9  10  11  12  13 

Popular C++ topics at The Database Managers:

Services | Programming | Contact Us | Recent Updates
Send feedback to: