#include<stdio.h>
int main(int argc, const char *argv[])
{
//两个整数相除,得到的还是整数;后面的小数部分会被直接舍去
float answer = 17 / 13;
printf("%.2f\n", answer);
return 0;
}
运行结果:
浮点数的转换:
#include<stdio.h>
int main(int argc, const char *argv[])
{
float answer = 17 / (float)13; // or float answer = 17 / 13.00
printf("%.2f\n", answer);
return 0;
}