Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!news.cs.indiana.edu!cs.widener.edu!sven From: sven@cs.widener.edu (Sven Heinicke) Newsgroups: comp.lang.c Subject: Re: When do you use "if ( a = b )"? (was Re: Funny mistake) Message-ID: <1991Mar17.161137.5081@cs.widener.edu> Date: 17 Mar 91 16:11:37 GMT References: <15481@smoke.brl.mil> <775@camco.Celestial.COM> <65837@eerie.acsu.Buffalo.EDU> Organization: Widener CS Dept Lines: 33 Nntp-Posting-Host: shirley.cs.widener.edu In <65837@eerie.acsu.Buffalo.EDU>, chu@acsu.buffalo.edu writes: >In article <775@camco.Celestial.COM> bill@camco.Celestial.COM (Bill Campbell) writes: >[concerning "if ( a = b )" > >It's been my mistake everytime I've done it!! I realize that it is a >legal construction and I know what it does, but I was wondering... >Is there a good use for this? > I went through some of the programs that I wrote and here is probely the best example of a good use for it that was kind of easy to understand (if finds the greatest common demonator of a and b). You can write the program without in in the while statment but it was the easest place I could find to put it. int gcd(a,b) int a,b; { int r,q; while(r = a%b) { q = a/b; a = b; b = r; } return(b); } -- sven@cs.widener.edu Widener CS system manager Sven Mike Heinicke and Student (pssmheinicke@cyber.widener.edu (if you must))