1. Home
  2. Computing & Technology
  3. C / C++ / C#
photo of David Bolton
David's C / C++ / C# Blog

By David Bolton, About.com Guide to C / C++ / C#

Answer to C Programming Puzzle

Wednesday August 13, 2008
That was too easy perhaps (malempati sussed what it did) though no one actually gave me the answer I was looking for. It's a recursive program as best I can make out and I had to set the stack size to a very large number (5 MB) on windows to stop it crashing.

If you want to see more examples of obfuscated code (I know I don't!) take a look at the past entries to the IOCCC website. This is the home of the International Obfuscated C Code Contest. If anyone want to send in their own original obfuscated code I'll put them on a special page in the C (or C++) code library.

Comments
August 14, 2008 at 6:38 am
(1) Harpreet says:

After looking at again carefully and reading the answer posted by David, I have re arranged the program in readable manner, now who are still unable to understand the answer can get the idea what is happening.

main program is calling function which is recursively calling itself depending upon result of ternary operator.

function name can be “_” a underscore and has arguments as ‘__’ ( single underscore) , ‘___’ ( double underscore) , ‘____’ ( triple ) . As no datatyope is mentioned for them so they are taken as “int” by default.

#include
#include

_(__,___,____)

{
___/__1&&___%__

August 14, 2008 at 6:40 am
(2) Harpreet says:

here is re arranged code

#include
#include

_(__,___,____)

{
___/__1&&___%__

August 14, 2008 at 6:43 am
(3) Harpreet \ says:

main is calling the function _(_,__,___) as shown with arguments:
main()
{
_(100,0,0);
}

August 14, 2008 at 6:48 am
(4) Harpreet says:

_(__,___,____)

{
___/__1&&___%__

August 14, 2008 at 6:49 am
(5) Harpreet says:

unable to paste re arrabged function :(

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore C / C++ / C#
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#

©2009 About.com, a part of The New York Times Company.

All rights reserved.