Choosing the correct type for the job : Short Calculation « Operator « C Tutorial






#include <stdio.h>

int main(void)
{
  const float Revenue_Per_150 = 4.5f;
  short JanSold =23500;
  short FebSold =19300;
  short MarSold =21600;
  float  RevQuarter = 0.0f;

  long QuarterSold = JanSold+FebSold+MarSold; 

  printf("Jan: %d\n Feb: %d\n Mar: %d\n", JanSold,FebSold,MarSold);
  printf("%ld\n",QuarterSold);

  RevQuarter = QuarterSold/150*Revenue_Per_150;
  printf("$%.2f\n",RevQuarter);
  return 0;
}
Jan: 23500
      Feb: 19300
      Mar: 21600
     64400
     $1930.50








5.6.Short Calculation
5.6.1.Choosing the correct type for the job