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#

An Interesting C Program and Puzzle

Monday August 11, 2008
I'm not sure if this will correctly format so I've also provided it as a download. It's a great example of how not to write a program and I found it on wikipedia.

#include <stdio.h>
_(__,___,____){___/__<=1?_(__,___+1,____):!(___%__)?_(__,___+1,0):___%__==___/
__&&!____?(printf("%d\t",___/__),_(__,___+1,0)):___%__>1&&___%__<___/__?_(__,1+
___,____+!(___/__%(___%__))):___<__*__?_(__,___+1,____):0;}main(){_(100,0,0);
}

It should compile (really!) and run but you may find it crashes. So the puzzle is, what do you need to do to make it run. Here's a big clue. Don't change any of the source code! You can search wikipedia but that won't tell you what's wrong... Answer on Wednesday. Have fun!

Comments
August 12, 2008 at 1:49 am
(1) malempati says:

program prints prime numbers between 0-100.
I tried on debian unix ..it doesn’t crash but prints prime numbers between 0-100.

August 13, 2008 at 12:27 am
(2) Ankit says:

yeah, it prints prime no.s between 1 & 100.
it doesnt crash. i used gcc compiler

August 17, 2008 at 12:26 pm
(3) Ashish Ranjan says:

This program will definitely work and not crash and it will display all the prime numbers between 1 to 100.
In this program symbol “_” is used as variable being very specific about the prog.
“_” is used as a function name &
“_”, “__”& “___” are the variable name

September 23, 2008 at 3:17 am
(4) sathish says:

Could someone comment on the logic used here.

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.