Home Segments Index Top Previous Next

643: Mainline

Alternatively, but perhaps inelegantly, you could use the VERBOSE macro to control displaying in an ifelse combination. You would compile one version of the program with the VERBOSE macro defined to substitute 1 into a Boolean expression. Then, you would recompile the same program with the VERBOSE macro defined to substitute 0 into that Boolean expression:

/* 
   Define VERBOSE to insert 1 if you want two complete sentences. 
   Define VERBOSE to insert 0 if you want two numbers only. 
*/ 
#define VERBOSE 1 
// Bulk of program goes here 
  /* Perform analysis */ 
  if (VERBOSE) { 
    printf ("The mean price per share of the trades is %.2f.\n", 
            mean_price (trade_pointers, limit)); 
    printf ("The mean number of shares traded is %.0f.\n", 
            mean_size (trade_pointers, limit)); 
    } 
  else { 
    printf ("%.2f %.2f",  
            mean_price (trade_pointers, limit), 
            mean_size (trade_pointers, limit)); 
  } 
}