In the next gcc.gnu.org article, Nathan Myers says that the C ++ skills test at SANS Consulting Services contained three errors in nine questions:
Looking back, one of the first online C ++ tests I came across was: http://www.geekinterview.com/question_details/13090
I looked at question 1 ...
find(int x,int y) { return ((x<y)?0:(xy)):}
call find (a, find (a, b)) to use for searching (a) maximum a, b (b) minimum a, b (c) positive difference a, b (d) sum a, b
... immediately wondered why anyone would write something so dumb. Passing by the absurd, I did not like any of the answers, immediately eliminating (a) and (b), because you can return to zero (which is neither a nor b) in a variety of circumstances. The sum or difference seemed more likely, except that you could also get zero regardless of a and b. So ... I ran Matlab (code below) and found: when either a or b is negative, you get zero; when b> a you get; otherwise you will get b, so the answer will be (b) min (a, b) if a and b are positive, although, strictly speaking, the answer should not be any of the above, since there are no range restrictions for any variable. This forces the subjects to solve the dilemma - choose the best available answer and make a mistake in 3 of 4 quadrants, or do not answer, leaving the door open to conclude that the grader believes that you cannot understand this.
The solution for testers is to fix the test, but in the meantime, what is the right course of action for testers? Complain about questions?
function z = findfunc(x,y) for i=1:length(x) if x(i) < y(i) z(i) = 0; else z(i) = x(i) - y(i); end end end function [b,d1,z] = plotstuff() k = 50; a = [-k:1:k]; b = (2*k+1) * rand(length(a),1) - k; d1 = findfunc(a,b); z = findfunc(a,d1); plot( a, b, 'r.', a, d1, 'g-', a, z, 'b-'); end