Problem with ()?():() as ending test in for-loop
vanpetegem at liszt.kulesat.uucp
vanpetegem at liszt.kulesat.uucp
Wed May 24 04:53:21 AEST 1989
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 at blekul60
Kardinaal Mercierlaan 94 UUCP: vanpetegem at kulesat.uucp
3030 Heverlee
BELGIUM
===============================================================================
More information about the Comp.lang.c
mailing list