On Dec 29, 2010, at 07:30 AM, Olin Lathrop wrote: > PETER ONION wrote: >>>> if(diff >=3D 0) >>>> byte =3D 0; >>>> else >>>>=20 >>>> { >>>> byte =3D 8; >>>> diff =3D - diff; >>>> } >>=20 >> The ";" just terminates the "if true statement". >=20 > But if a semicolon doesn't end the IF statement, what does end it > unambiguously? Or put another way, what if there was a outer IF not show= n > above, and ELSE was meant to be part of it, not the IF shown. How would = you > then end the IF shown so that the ELSE would not be part of it? >=20 Semicolons do not terminate an if statement. In C, if statements will exec= ute a single block of code following the if and the else (note: 'else if' s= tatements just build on the above method). The single block of code in the= above is considered to be the line following the if and the code with the = { } following the else. An un-compiliable example: if(i >=3D 0) byte =3D 0; //executes on condition byte++; //always runs else //syntax error, HAL is not pleased { byte =3D 99; } If this could be run, line 2 is executed if i >=3D 0 is true. Line 3 is al= ways executed (note the nesting makes this ambiguous). Then line 4, would = be an orphaned else with no preceding if and the code will not compile. If the programmer intents to execute what most of us see when we look at th= e above, the block to execute following the if needs to be enclosed: if(i >=3D 0)=20 { byte =3D 0; byte++; } else { byte =3D 99; } --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .