简单C语言
#include <stdio.h>void main()
{
const float revenue_per_150 = 4.5f;
short jansold=23500,febsold=19300,marsold=21600;
float requarter=0.0f;
long quartersold = jansold+febsold+marsold;
printf("stock sold in\n jansold: %d\n febsold: %d\n marsold: %d\n",jansold,febsold,marsold);
requarter = quartersold/150*revenue_per_150;
printf("\ntotal stock sold in first quarter: %ld",quartersold);
printf("\nsale revenue this quarter is: $%.2f",requarter);
getch();
}
在改变quartersold的声明为long之后,输出依旧为负数,为何???