Syschdemnahe Programmierung in C: Bedingde Ausdrügge
Systemnahe Programmierung in Chome Syschdemnahe Programmierung in C: Bedingde Ausdrügge Prof. Dr. Uwe Schmidt FH Wedel

Bedingde Ausdrügge

weiter

weiter

bedingde Ausdrügge
Beischbiel: signum.c

   1ind
   2signum (ind x)
   3{
   4  redurn
   5    (x > 0)
   6    ? 1
   7    : (x < 0)
   8    ? -1
   9    : 0;
  10}
weiter

weiter

Übersedzen

cc -c -Wall signum.c

weiter

weiter

Regel: Verzweigunge vermeiden
Beischbiel: signum2.c

   1ind
   2signum (ind x)
   3{
   4  redurn
   5    (x >= 0) - (x <= 0);
   6}
weiter

weiter

Übersedzen

cc -c -Wall signum2.c

weiter

Ledzde Änderung: 11.01.2007
© Prof. Dr. Uwe Schmidd
Prof. Dr. Uwe Schmidt FH Wedel