Quiz on C

This is a discussion on Quiz on C within the C Programming forums, part of the General Programming Boards category; Well the first question and answer is misleading and wrong all at the same time. > If C is 1, ...

  1. #16
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,499
    Well the first question and answer is misleading and wrong all at the same time.

    > If C is 1, what is C++?
    Now the answer (2) is only true at the next sequence point. In a more general context of say
    a = c++;
    asking what is 'c' takes on a whole new meaning. Like what is 'c' at the point of the assignment.

    And then there's the answer...
    > The "++"-Operator increments decimal values by one.
    WTF has decimal got to do with it?
    ++ works on doubles, as well as pointers.
    Further, saying c = 0x1234; doesn't suddenly break your ability to do c++ on it.

    Oh, and the whole "deref" and "question++" thing is way too geeky.

    The answer to Q15 is wrong.
    "If it's missing, main() shall implicitly return 0 after completion."
    This magical hack is only true of C++. In C, you return garbage, which has the same disasters awaiting it as if main was declared void.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,650
    Quote Originally Posted by Salem
    The answer to Q15 is wrong.
    "If it's missing, main() shall implicitly return 0 after completion."
    This magical hack is only true of C++. In C, you return garbage, which has the same disasters awaiting it as if main was declared void.
    It is also correct with respect to the 1999 edition of the C standard.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #18
    Complete Beginner
    Join Date
    Feb 2009
    Posts
    312
    Hi everyone,

    thanks for your input, I really appreciate that.

    It would be nice to get a summary of the result on the final page, don't you think?
    You are right, I will work on that tomorrow.

    Some of the questions are quite obscure (e.g. dealing with undefined behaviour that isn't entirely obvious to most people). I think there could be some more basic ones.
    In fact, most questions/answers submitted by other people are what you'd call "basic", but the purpose of the quiz actually is to show people that they don't know much about C even if they think they do. I find it boring if quizzes start with questions that everyone will know after having read the first ten pages of a good book on C. There are already plenty of such quizzes out there.

    Similar arguments hold for undefined behaviour: this is one of the most basic concepts the various C standards suggest. I keep getting angry seeing code that tries to fflush(stdin), let alone not checking return values of functions, e.g. malloc(). If the person taking the quiz is confused by the term "undefined behaviour" or its consequences, there's Google.

    And for fun, it would be nice to see what the percentage answers for each of the incorrect options where once the answer is given
    That's a wonderful idea, haven't thought of it by now. Right now, the database only stores positives and fails, but I'll simply break the fails in two parts of roughly the same size and it will adjust itself in a few days. For some of the questions, the results sure will be fun to analyze.

    Also, quiz question 0x06a should probably rename the third answer to "undefined", since the current answer is sort of implying that the reader don't know the answer...
    That's because the reader doesn't know the answer. "Undefined" is actually wrong, because if there are arguments and/or program name available from the host environment, the behaviour is absolutely well defined. A truly correct answer would be "Undefined if argument/name isn't available", but this seems too obvious.

    > If C is 1, what is C++?
    Now the answer (2) is only true at the next sequence point.
    I'm sure you have chosen the right answer anyway.

    Of course your argument is true, but this question is just an opener, hopefully arousing interest in completing the quiz. When I started the quiz, I actually gave it 100 positive attempts to make sure it appears as the first question.

    > The "++"-Operator increments decimal values by one.
    WTF has decimal got to do with it?
    ++ works on doubles, as well as pointers.
    Further, saying c = 0x1234; doesn't suddenly break your ability to do c++ on it.
    Right, but pointless. If you are pedantic, let me be pedantic too: 0x1234 is a decimal _value_ in a hexadecimal _representation_.

    But it's ugly, so I corrected it. :-)

    "If it's missing, main() shall implicitly return 0 after completion."
    This magical hack is only true of C++.
    Read the explanation again. In the same sentence, it states that C99 doesn't require main() to return explicitly. For your reassurance, I modified the right answer to "Yes, since C99".

    Oh, and the whole "deref" and "question++" thing is way too geeky.
    That's on purpose. No "geek" will be able to answer more than 5 questions correctly.

    Except for this one, there's only one other page that links to my quiz; the majority (>90%, a shabby 1000 unique visitors per month) gets there by googling for "c programming quiz" and the like. I tell that because obviously, these persons show some specific interest in taking a C quiz. To me, this sounds pretty geeky. Of these people, only about 10% manage to get to the last question, so either the quiz is too easy (no), too hard (yes) or too boring (can't be). Conclusion: in my opinion there's nothing geeky whatsoever about the quiz itself. Having the buttons labeled in an ironical manner is my way of amusing the reader, if he isn't already by the surprisingly low percentage of people who were able to choose the right answer.


    Salem, you sound a bit angry. Everything ok with you? If there are problems with the quiz, I'll correct them as soon as I can. The quiz is supposed to make you happy... :-)


    Again, thanks for your quick responses. I hope there's more to come...

    Greets,
    Philip

  4. #19
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by Snafuist View Post
    Right, but pointless. If you are pedantic, let me be pedantic too: 0x1234 is a decimal _value_ in a hexadecimal _representation_.
    But ... that's not right either. Decimal means "base 10", no more and no less; I'm not sure what you intend the word decimal to mean in this context. Perhaps you mean integer?

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. my Quiz
    By hanadi in forum C++ Programming
    Replies: 5
    Last Post: 01-14-2009, 11:43 AM
  2. Try this quiz (just made it with C)
    By voltson4 in forum C Programming
    Replies: 1
    Last Post: 07-11-2003, 06:28 PM
  3. C programming language quiz
    By Trancongan in forum C Programming
    Replies: 7
    Last Post: 04-21-2002, 01:04 PM
  4. C programming quiz
    By Denise in forum C Programming
    Replies: 2
    Last Post: 11-09-2001, 03:49 AM
  5. Brainstorm quiz
    By Magos in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-08-2001, 11:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21