Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!ames!xanth!mcnc!ecsvax!utoddl From: utoddl@ecsvax.UUCP (Todd M. Lewis) Newsgroups: comp.misc Subject: Re: Silly programming problems Message-ID: <6686@ecsvax.UUCP> Date: 20 Mar 89 14:03:24 GMT References: <817@krafla.rhi.hi.is> <984@masscomp.UUCP> Organization: UNC Educational Computing Service Lines: 33 In article <984@masscomp.UUCP>, ftw@masscomp.UUCP (Farrell Woods) writes: > In article <817@krafla.rhi.hi.is> frisk@rhi.hi.is (Fridrik Skulason) writes: > >I am looking for some silly but difficult problems for use in a contest. > > I saw this once on a midterm exam given in a first-semester Pascal course. > It was one of those "find all the syntax errors in the following program" > deals. The same stunt can be applied in C as well. For sake of brveity, > I've shortened the example: > > program foo(input, output) > > begin > > [ body of foo ] (* some miscellaneous comment in the middle of foo * ) > (* which of course was obscured by other comments *) > > end. Which is an excellent example demonstrating the desirability of (* Nested (* Comments *) *). If nested comments were the norm, the above program would have produced a compile-time error to the effect of "comment from line ## not terminated. Unexpected end of text". This can be applied in C as well (is there an echo in here). In that case, you wouldn't have to use those ugly preprocessor directives to "comment out" sections of code. Don't get me wrong, I like the preprocessor for what it is, but using it for comment delineation is Simply Wrong (IMHO). _____ | Todd M. Lewis Disclaimer: If you want my employer's ||\/| utoddl@ecsvax.uncecs.edu ideas, you'll have to || || _buy_ them. | || |___ (Never write a program bigger than your screen.)