Path: utzoo!attcan!uunet!mcvax!prlb2!kulcs!kulesat!esat!vanpetegem From: vanpetegem@liszt.kulesat.uucp Newsgroups: comp.lang.c Subject: Problem with ()?():() as ending test in for-loop Message-ID: <1200@liszt.kulesat.uucp> Date: 23 May 89 18:53:21 GMT Organization: Katholieke Universiteit Leuven,ESAT - dep. Elect. Engineering, Belgium Lines: 42 Hello every C programmer there, I have a problem with VAX C V2.4-026 under VMS V5.0-2. The code with which I am in trouble, goes as follows: for(n = 1; ((n % 10) ? (k > 2) : (n < 100)); n++) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ { ..... (in some expressions k is changed, depending on n) } What I want to do is simply perform the test (k > 2) as ending test for the "for-loop", except in the cases where n is dividable by 10. In the latter situation the test (n < 100) has to be done. But... When n becomes equal to 10 the "for-loop" is stopped already. So I think neither the first nor the second test is evaluated and only (n % 10) is taken into account (the first test (k > 2) is only important for n taking values from 50 on). Is the above syntax not allowed (I doubt: the compiler gives no error messages) ? Or what is wrong with it ? Any suggestions to overcome this problem ? Thanks in advance for every answer that can help me. Wim VP. =============================================================================== Wim Van Petegem Phone: + 32 16 / 22 09 31 (1083) Katholieke Universiteit Leuven Telex: 25941 elekul Departement Elektrotechniek Fax: + 32 16 / 22 18 55 Afdeling ESAT-MICAS BITNET: vanpetegem%kulesat.uucp@blekul60 Kardinaal Mercierlaan 94 UUCP: vanpetegem@kulesat.uucp 3030 Heverlee BELGIUM ===============================================================================