/*
   Program: mix.c

   Testing mixing floating and integer types.
*/

#include <stdio.h>
#include"genlib.h"
#include"simpio.h"

main() {

  double x ;
  int i ;

  /* a double constant assigned to an integer variable */
  i = 2.7 ;
  printf("i = %d\n", i) ;

  /* an integer constant assigned to a double variable */
  x = 3 + 4 ;
  printf("x = %f\n", x) ;
  
  /* Mixing doubles and integers results in a double */
  printf("\n") ;
  printf("Nine divided by four: %f\n\n", 9.0/4.0) ;
  printf("Nine divided by four: %f\n\n", 9/4.0) ;
  printf("Nine divided by four: %f\n\n", 9.0/4) ;

  /* A nasty surprise */
  printf("Nine divided by four: %f\n\n", 9/4) ;

  /* Avoiding nasty surprises */
  x = 9/4 ;
  printf("Nine divided by four: %f\n\n", x) ;
  printf("Nine divided by four: %f\n\n", (double) (9/4) ) ;
}
