Like Tree1Likes
  • 1 Post By rags_to_riches

C Programming Puzzles

This is a discussion on C Programming Puzzles within the C Programming forums, part of the General Programming Boards category; <Post removed>...

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    6

    Post C Programming Puzzles

    <Post removed>
    Last edited by nirmaljoe1; 05-10-2011 at 12:25 PM. Reason: Removing the post.

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Except the code is not indented, which is completely ridiculous.

    Somebody at "<<OP doesn't care anymore>>" needs to read this:

    Paragraphs, Lines, and Phrases
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,505
    If you learn from that mess, you're learning a load of rubbish.

    All the ones with void main are wrong.
    All the ones which assume string literals are writeable are wrong.
    All the ones which assume evaluation order are wrong.
    All the ones which assume specific sizes for int, pointer etc, are compiler specific (without you saying which compiler it is, though I can guess it's probably TurbidCrap).
    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.

  4. #4
    Registered User
    Join Date
    May 2011
    Posts
    6
    Salem, Its my friend's website.Can you help with your valuable comments in a positive way.He actually wants someone to correct and help him in posting good quality articles in that website.You can post your valuable comment in that website. Thanks to you in advance for my friend...

  5. #5
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,468
    Worse than that, these puzzles look like they were written by somebody using the undead Borland Turbo C compiler. This sounds like shameless self promotion. For anybody attempting to learn from that site, don't! There are numerous problems. In my first read-through of the questions, I noticed the following problems:
    1. Cprogramming.com FAQ > main() / void main() / int main() / int main(void) / int main(int argc, char *argv[])
    2. far pointers haven't existed since the 16-bit DOS days
    3. #2 has an incorrect leap year check. It's years that are divisible by 4, except those divisible by 100 unless they're divisible by 400
    4. #9 assumes 16 bit integers, which is highly unlikely, and big-endian, which is system dependent
    5. #20 is wrong, the order in which function parameters are evaluated is unspecified
    6. #23 is wrong, if printf doesn't have enough parameters for the format specifiers, the behavior is undefined


    EDIT: I just noticed your friend has 3 other pages full of bad examples. He ought to take down those things before they cause any harm. I applaud the effort, but your friend is just not ready to share his "knowledge" of C with the rest of the world. And I doubt anybody here wants to read through 100 examples of horribly formatted code with things like "void main", that make most respectable C programmers want to vomit. Tell him to get an up to date compiler, compile all his examples with the strictest warnings on and read the standard to verify that what he's trying to teach is actual proper C.
    Last edited by anduril462; 05-10-2011 at 11:47 AM.

  6. #6
    Registered User
    Join Date
    May 2011
    Posts
    6
    You are correct Anduril. I think he has collected these questions from some placement papers used by some Indian software companies.Its really shame that still our top IT companies use outdated questions and forcing people to be fools.Present job placement tests are not enough to measure the actual programming skills.

  7. #7
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by nirmaljoe1 View Post
    You are correct Anduril. I think he has collected these questions from some placement papers used by some Indian software companies.Its really shame that still our top IT companies use outdated questions and forcing people to be fools.Present job placement tests are not enough to measure the actual programming skills.
    So... World time 2011 ... India time 1978?

    (But not to worry... Where I live it's still 1956)

  8. #8
    Registered User
    Join Date
    May 2011
    Posts
    6
    Quote Originally Posted by CommonTater View Post
    So... World time 2011 ... India time 1978?

    (But not to worry... Where I live it's still 1956)
    CommonTater,Don't tell like that.Its applicable to only some service companies.We shouldn't make a prejudice about all companies.

  9. #9
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by nirmaljoe1 View Post
    CommonTater,Don't tell like that.Its applicable to only some service companies.We shouldn't make a prejudice about all companies.
    Neither do I ... but based on what we've seen here in the past few months, it's very hard not to.

    There was a guy here the other day still running MS-DOS... WOW!

  10. #10
    Registered User
    Join Date
    May 2011
    Posts
    6
    I would like to consider this as a positive opportunity to find mistakes and strengthen our knowledge by discussing and correcting the errors.

  11. #11
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by nirmaljoe1 View Post
    I would like to consider this as a positive opportunity to find mistakes and strengthen our knowledge by discussing and correcting the errors.
    How about we consider it a positive opportunity to not have more crappy code floating around for the rest of us to end up correcting?

    The others have pointed out *many* deficiencies in the code and the puzzles... stop discussing and start fixing.

  12. #12
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,468
    I should have made a new post instead of editing my old one:
    Quote Originally Posted by anduril462 View Post
    EDIT: I just noticed your friend has 3 other pages full of bad examples. He ought to take down those things before they cause any harm. I applaud the effort, but your friend is just not ready to share his "knowledge" of C with the rest of the world. And I doubt anybody here wants to read through 100 examples of horribly formatted code with things like "void main", that make most respectable C programmers want to vomit. Tell him to get an up to date compiler, compile all his examples with the strictest warnings on and read the standard to verify that what he's trying to teach is actual proper C.

  13. #13
    Registered User
    Join Date
    May 2011
    Posts
    6
    Sure, I will communicate all these corrections and suggestions to my friend.He will correct them soon.

  14. #14
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    So another words, it's just another Indian cheat your way through school and into the workforce site? Nice. There's certainly a shortage of those. How pathetic.
    CommonTater likes this.

  15. #15
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,505
    OP no longer interested, so nothing more to add.
    Closed.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. small programming job VCPP / Object Oriented Programming
    By calgonite in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 01-04-2006, 10:48 PM
  2. C/C++ puzzles
    By sunnypalsingh in forum C Programming
    Replies: 2
    Last Post: 10-14-2005, 10:41 AM
  3. Puzzles...
    By Perspective in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-11-2004, 11:28 AM
  4. Total newb to programming here... Question about the many programming languages. Ty!
    By tsubotakid1 in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 10-05-2003, 10:32 AM

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