A friend of mine posted this little quiz on Google+ not too long ago, and I thought you guys might get a kick out of it if you haven't seen it before. I haven't seen C++ code in ages (I'm a Java-based code monkey myself), but I was still able to get some of the questions right. Fair warning: some of the code present is a major eye sore. Not quite THAT bad though.
Spot the bug quiz.
That looks fun, but I cannot play on this little phone! Too many instances of me screaming " NO! Not the comma! Arrgh!"
I'll have to wait until I get home.
As to that other link you posted.. O.o Oh. My. God!
11 / 15.
I assumed it has to be a bug while one of answers was simply a misplaced semicolon. Didn't expect that.
12/15, thought it only gave me 11/15 because in the misplaced bracket question I identified the problem correctly but clicked on the == instead of the misplaced bracket (it seemed reasonable, honestly, that was unfair) so I just gave myself the point. I didn't spot the misplaced semicolon either somehow, goes to show how these things are easy to miss!
12/15, thought it only gave me 11/15 because in the misplaced bracket question I identified the problem correctly but clicked on the == instead of the misplaced bracket (it seemed reasonable, honestly, that was unfair) so I just gave myself the point. I didn't spot the misplaced semicolon either somehow, goes to show how these things are easy to miss!
Yeah, same thing happened to me. And in one case i misclicked by one character.
Ohh, I earn a title of "Pedant of C++".
Most of those were copy/paste bugs, and their names were pretty bad, or at least looked bad out of context.
Fun little quiz.
Ohh, I earn a title of "Pedant of C++".
Most of those were copy/paste bugs, and their names were pretty bad, or at least looked bad out of context.
Fun little quiz.
I thought the same thing to myself. Not to mention, a good chunk of those bugs weren't really C++ specific. They could have happened in any language. For instance, there was a lot of bugs where people wrote
x0 - x1;
y0 - y1;
y0 - z1;
which can literally happen in any language. Some things, however, were classic C++ wtf moments.
Nice touch that all the samples come from real life projects, and you even get to know which project :)
Interesting quiz, but it's too picky about what you're supposed to click on. In some cases, I wanted to select the entire code snippet.
Yeah I gave up on the memcmp(a,b,c == 0) question (which should be memcmp(a,b,c)==0)
My answer was "The ==0 is in the wrong place, it needs to be after the close-parenthesis", so I clicked on the ==.
But then the quiz said "Nope! The close-parenthesis is in the wrong place, it needs to be before the ==".
![]()
Yeah I gave up on the memcmp(a,b,c == 0) question (which should be memcmp(a,b,c)==0)Interesting quiz, but it's too picky about what you're supposed to click on. In some cases, I wanted to select the entire code snippet.
My answer was "The ==0 is in the wrong place, it needs to be after the close-parenthesis", so I clicked on the ==.
But then the quiz said "Nope! The close-parenthesis is in the wrong place, it needs to be before the ==".
But the "==" is exactly where it should be! The ")" is out of place!
2 out of 15 - Should not be allowed near C++ :P
Granted however, I never programmed C++, only a bit of ANSI-C and now I only do C#
11/15. an intersting quiz, they do a good job for the most part, except when you have to identify missing pieces of code, and i have to guess which symbol they want me to click to be "correct".
Some of those I'm even surprised that I got.
I think there was a question that dealt with local variables being returned from a function by reference. Obviously, that's... a case of a dangling pointer I think, but if you're a Java programmer... what's a dangling pointer? One time I came back to C++ for a quick project, and I'm surprised to this day that I remembered that fact as if I've kept it in mind all this time.
That's a pretty good way to make the case for static analysis.
Very nice :)
One or two of these cases had me with their definition of the wrongly placed symbol.
They need to include some famous bugs **cough**goto fail** :)
6/15
I really liked it. At first I was going with the mentality of "This is going to be an operator precedence test" so I looked at all the wrong places
Then it became clear that it was just a general bugs thing. Really liked the thing about misplaced parenthesis, or bugs in long blocks of similar code.
Obviously, that's... a case of a dangling pointer I think, but if you're a Java programmer... what's a dangling pointer?
Eh if you ever touched any kind of language that lets you use pointers you'll probably remember it. I mean, I didn't got it right but when it said "returning reference to a local variable" I was like "Oh, duh!", I know what it is, I just wasn't looking for it.
Then again I advocate learning with something like C or Pascal variants, and only then moving onto managed or scripting languages. Exclusively learning and using managed languages seems like a bad idea to me.
Then again I advocate learning with something like C or Pascal variants, and only then moving onto managed or scripting languages. Exclusively learning and using managed languages seems like a bad idea to me.
I myself started with C++ I think. It was alright, but knowing what I know now, I don't know if today I wouldn't start with Python first. I don't even like the language, but at my internship Python is the main flavor of the proverbial kool aid. Personally, I find it annoying, but it might be more so because I've been using Java for the vast majority of my programming career. It is by no means a bad language. I'm simply not proficient in it.
Then again I advocate learning with something like C or Pascal variants, and only then moving onto managed or scripting languages. Exclusively learning and using managed languages seems like a bad idea to me.
I kind of disagree - starting with a managed or more "scripting-like" language can get the person interested in programming in the first place because of how easy it is to get the computer to do something. You don't have to deal with a lot of the boilerplate ceremony that lower-level languages foist on you. Heck, I started with a BASIC variant as a kid - and while it isn't as high level as something like Python, I could get a simple guess the number game working quickly.
Of course, once you you've got them hooked, then teach them the lower level stuff so their skills improve. Knowing how to code in a lower-level language with manual resource management I think is critical to being a good programmer - but you don't have to start there.
I'm of two minds on that - I find that those who start with managed languages tend never to achieve as high a degree of proficiency in lower-level programming.Of course, once you you've got them hooked, then teach them the lower level stuff so their skills improve. Knowing how to code in a lower-level language with manual resource management I think is critical to being a good programmer - but you don't have to start there.
In a way, I guess it's hard to catch up to someone who cut their teeth on C, assembly and hardware architectures.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.