Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!andrew.cmu.edu!tg1e+ From: tg1e+@andrew.cmu.edu (Timothy R. Gottschalk) Newsgroups: comp.lang.c Subject: swap(x,y) Message-ID: Date: 22 Aug 89 06:34:57 GMT Organization: Carnegie Mellon, Pittsburgh, PA Lines: 14 To swap two variables x,y in C without using a temporary variable: /* begin swap */ x += y; y = x - y; x -= y; /* end swap */ Just curious...(this looks pretty valid) does anyone know an even simpler method? I would never program this way -- it's more of a theory question. I've been told that it can't be done (???). Tim Gottschalk Pgh, PA