home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18203 < prev    next >
Encoding:
Internet Message Format  |  1992-12-11  |  1.6 KB

  1. Path: sparky!uunet!crdgw1!rdsunx.crd.ge.com!bart!volpe
  2. From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Question to test general C knowledge
  5. Message-ID: <1992Dec11.180939.20726@crd.ge.com>
  6. Date: 11 Dec 92 18:09:39 GMT
  7. References: <Bz0A46.Cvu@watserv1.uwaterloo.ca> <19980@ksr.com> <1992Dec11.091819.26636@thunder.mcrcim.mcgill.edu>
  8. Sender: volpe@bart (Christopher R Volpe)
  9. Reply-To: volpe@ausable.crd.ge.com
  10. Organization: GE Corporate Research & Development
  11. Lines: 35
  12. Nntp-Posting-Host: bart.crd.ge.com
  13.  
  14. In article <1992Dec11.091819.26636@thunder.mcrcim.mcgill.edu>, mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
  15. |> In article <19980@ksr.com>, jfw@ksr.com (John F. Woods) writes:
  16. |> > dmeister@mansci1.UWaterloo.ca (Darren Meister) writes:
  17. |> >> [I]f you could ask someone one question to test if they generally
  18. |> >> understand C what would it be[?]
  19. |> 
  20. |> > "After
  21. |> >     int i = 2;
  22. |> >     i = ++i;
  23. |> >  what does i equal?"
  24. |> 
  25. |> > If they answer, do not hire them.
  26. |> 
  27. |> Hm?
  28. |> 
  29. |> "Anything or nothing.  3 seems most probable, with 4 next."
  30.                                                  ^^^^^^^^^^^^
  31.  
  32. Why? The effect of the "++" is to assign 3 to i. And since the value of
  33. the "++i" expression is 3, the effect of the "=" is to assign 3 to i. 
  34. Under what conditions would any other value be expected? (Other than,
  35. of course, a vindictive compiler that detected violations of the letter
  36. of the law and went out of its way to give you garbage.)
  37.  
  38.  
  39. |> 
  40. |>                     der Mouse
  41. |> 
  42. |>                 mouse@larry.mcrcim.mcgill.edu
  43.  
  44. -- 
  45. ==================
  46. Chris Volpe
  47. G.E. Corporate R&D
  48. volpecr@crd.ge.com
  49.