/* Basic mathematical operations */

#include <stdio.h>

void main(void) {

  int operand1;
  int operand2;

  float fp_operand1;
  float fp_operand2;

  operand1 = 6;
  operand2 = 12;

  operand1 = operand1 + operand2;             /* 18 */
 
  operand1 = operand1 * operand1;             /* 324 */

  operand1 = operand1 / 5;                    /* 64 (actually 64.8 
                                                 but integers only
                                                 store integral 
                                                 values)*/

  operand1 = operand1 % 3;                    /* 1 */

  printf("operand1 is %i\n", operand1);       /* `operand1 is 1' 
                                                 printed on the 
                                                 screen */

  fp_operand1 = 1.5;
  fp_operand2 = 2.5;

  fp_operand1 = fp_operand1 * fp_operand2;    /* 3.75 */

  fp_operand1 += fp_operand2;                 /* 6.25 */

  fp_operand1 /= operand2;                    /* 0.520833 - 
                                                 dividing a float 
                                                 by a int is OK */

  operand2 /= fp_operand2;                    /* 4 (4.8 but again 
                                                 we lose the 
                                                 decimal part) */

  printf("fp_operand1 is %f, operand2 is %i\n", fp_operand1, operand2);
                                              /* `fp_operand1 is 
                                                 0.520833, operand 
                                                 2 is 4' printed 
                                                 on the screen */
}
