home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************
- * CH03_04.C L'opΘrateur ternaire *
- *********************************************************************/
-
- #include<stdio.h>
-
- main( void)
- {
- float a= -5.43, b= 3.21, test0, test1, test2, Min, Max;
-
- test0= ( a> 0) ? ( a): ( -a);
- /* renvoie la valeur absolue. */
- printf(" test0= %f", test0);
-
- test1= ( a> b) ? ( a- b): ( b- a);
- /* renvoie la valeur absolue de la diffΘrence. */
- printf("\n test1= %f", test1);
-
- test2= ( test0> b) ? ( test0- b): ( b- test0);
- /* a est remplacΘ par sa valeur absolue avant le test. */
- printf("\n test2= %f", test2);
-
- Min= ( a< b) ? a: b;
- /* renvoie la valeur du plus petit. */
- printf("\n Min= %f", Min);
-
- Max= ( a> b) ? a: b;
- /* renvoie la valeur du plus grand. */
- printf("\n Max= %f", Max);
- }
-
- /*
- test0= 5.430000
- test1= 8.639999 au lieu de 8.64 c'est une erreur d'arrondi!
- test2= 2.220000
- Min= -5.430000
- Max= 3.210000 */