Subj : Re: Really **wonderful** website for C interview questions!!!!! To : comp.programming From : Robert Bunn Date : Wed Jul 06 2005 01:18 pm "Robert Maas, see http://tinyurl.com/uh3t" wrote in message news:REM-2005jul06-004@Yahoo.Com... > > You shouldn't give up when you had that perspicuous answer to the quiz > question! Maybe you're really bright but are too shy to realize it? Oh, no, I'm not too shy at all. I *know* I'm really bright. I'm just really inexperienced with programming. Back in the 80s I could do nifty things with BASIC, but I never focused enough to develop any *real* programming ability. > > By the way, what would you call this code? > z = (y?(x?1:0):(x?0:1)) > I'm not asking what function it computes, rather what do you call the > *style* of expressing the answer computed/organized with that > particular structure. Hint, initials T.T. Don't look ahead, try to > figure it out before I give away the answer below. > It took me a minute, but I managed to get to "truth table" even before I looked at the hints. > > Now for a real tough question on an exam (open book, open InterNet): > Write a pair of functions (in whatever programming languge is being > tested) to convert between ASCII and EBCDIC. > [snip] > Smart-ass Hacker would find the Web site that mentions how HP and IBM > and AT&T EBCDIC are different, hence the question is ambiguous. Nah. Write a quick telnet wrapper, and ask the EBCDIC machine for which you're converting how it represents the character. Then return that value. This ensures you get the *right* EBCDIC for the machine in which you're interested. If the conversion is frequent, use a std::map to store a conversion table. If speed is a lot more important than code size or RAM footprint, keep two conversion tables, one for each direction. If storage space is available, write the table(s) to a conversion file so you can still use the program if the network is temporarily unavailable. Advantages: * Guarantees correct conversion for the case of interest * Insulates against future changes in the EBCDIC representation (e.g., due to a new machine replacing the one you programmed for) * Insulates the programmer from having to ever know what the EBCDIC representation looks like -- Rob .