Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C programming quiz, too difficult?

Status
Not open for further replies.

slakr

Programmer
Aug 24, 2004
6
US
My company is looking for a C developer and we have created a quiz. We have gotton some responses saying the quiz was too difficult. Other than the programmers I work with, I don't know any programmers to ask if the quiz is really too hard. So, I thought if I ask some anonymous C coders online, someone could tell me. It might be that the ones claiming it was too hard were simply not skilled enough for the job.

Can anybody help me do a reality check and take a look at the quiz? Is it too hard? Is it too time consuming?

Quiz:
Thanks,
/sLaKr
 
Seems quite reasonable to me, assuming the quizztakers know ahead of time details like the allowed/expected GUI toolkits and thread APIs.


To answer #9 as a smartass:

Bonjour, tout le monde!
 
>>allowed/expected GUI toolkits and thread APIs
Well, I only say you have to follow the C89 spec. Meaning, no fancy C99 tricks. Maybe I should put a blurb on top saying any toolkit can be used.

As for the smartass, you are correct. The answer is, the question does not specify that that it must be a programming language, instead it says "...in any language". It also says to "print", so cursive would be incorrect. So, the super duper answer to #9 is:

9. Hello World

Thank you for taking the time to look at the quiz. I appreciate it. I don't feel it is too hard either but being its author I am a bit biased.
 
Number 9
Code:
echo type hello world && cat -

Your bonus question is answered in K&R-2 if I remember correctly.

I agree with the others, this is more time consuming than difficult.

For me, there should be two additional questions.
1. The following piece of code contains a number of bugs. Read the functional description and fix the problem(s)
Code:
// prints hello world 10 times
int main ( ) {
  unsigned int i = 10;
  while ( i-- > 0 ) printf( "hello world\n" );
}
Which I think contains 4 problems.

But pick an example which is both a bit longer and contains more subtle problems.


2. Provide a short and slightly vague specification for some small piece of work. Ask for
- initial design suggestions
- points to clarify
- anything else they think they should mention

These should reveal more real world experience in actually developing software than simply being able to search the web for prior examples and being able to read the manual pages.


--
 
this seems to work for "is a power of 2"

Code:
_Bool IsPow2(int num)
{
    return num && !(num & (num-1))
}
 
Salem,

I can't find 4 things wrong with your "print hello world 10 times" program. I find:

1. no return for main
2. no stdio include
3. If we are following the specs of my quiz, you are using a C++ style comment

Other than that, the program works as advertised. You may have wanted the program to break in these ways:

1. only prints 9 times
2. using an unsigned value, you may have wanted the program to wrap the value of i, creating an infinite loop.

/sLaKr
 
Full marks to slakr :)

C99 allows // comments, C89 does not

The primary test is to spot the infinite loop.

--
 
>>The primary test is to spot the infinite loop.
It doesn't actually occur though. Your program doesn't enter an infinite loop. The last condition checked is

while( (0)++ > 0){...}

Since you are post-incrementing, when the while breaks out the value of `i` is 4294967295.

/sLaKr
 
sorry, I meant

while( (0)-- > 0) {...}

/sLaKr
 
slakr:
this quizz is normal difficulty.
nothing special about it.
those who complain should stick with VB and not pretend to be C developpers :D
 
IMO: C is so large and the various apis so disparate in
their approaches that unless your position needs a vanilla
flavored ansi style expert in-place you should be a little
more forgiving and less tricksy in your approach.

I tend to assume various things when I am looking at
sample code: otherwise I'd go nuts:
1.Correct includes.
2.Good libs and a smart compiler.
3.Types and type notation that is not unduly obscure.
4.Persons who actually won't ask stupid questions to try
to catch potentially stupid mistakes.

Otherwise you end up with a lot of elitist arsebags who
are familiar with the idiocy and a bunch of hungry people slurping soup in line who could probably improve things
if given the chance.

My .02 cents.

 
marsd,

Since my post in this forum about the cquiz, I have recieved many quiz sumbissions. About 80% get every question correct, about 10% miss a few things (question 5) and the rest fail. Those who fail, maybe getting a couple questions correct, do not have the "basic" skills needed for the position.

After getting these results, I am now confident that the test is fair and balanced. It also appears to be doing what it was intended to do, weed out those lacking the required skills. They don't seem to trick anyone worth hiring into "stupid mistakes". If you have 5+ years programming C (!C++ && !C# && !Java), as our job post requires, you should be able to answer those questions in your sleep.

Thank you for your input.

/sLaKr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top