课程
/后端开发
/C
/C语言入门
为什么这里是%f,而不是%d呢
2021-04-10
源自:C语言入门 3-1
正在回答
如果上边你定义result用的是int,输出的时候就用%d,如果是float,就用%f。整型用d,实型用f。
举报
C语言入门视频教程,带你进入编程世界的必修课-C语言
1 回答printf("%f\n",f);与printf("%lf\n",d); 的区别
3 回答#include <stdio.h> int main() { char c = 'a'; int n = c //将c赋值给n float f = n //将c赋值给f double d = f //将c赋值给d printf("%d\n",n); printf("%f\n",f); printf("%lf\n",d); return 0; }
2 回答char c = 'a'; int n = c ; //将c赋值给n float f = c ; //将c赋值给f double d = c; //将c赋值给d printf("%d\n",n); printf("%f\n",f); printf("%lf\n",d); return 0; }
1 回答#include <stdio.h> int main() { char c = 'a'; int n = c ; //将c赋值给n float f = c ; //将c赋值给f double d = c ; //将c赋值给d printf("%d\n",n); printf("%f\n",f); printf("%lf\n",d); return 0; }
4 回答#include <stdio.h> int main() { char c = 'a'; int n = c ; //将c赋值给n float f = c; //将c赋值给f double d = c; //将c赋值给d printf("%d\n",n); printf("%f\n",f); printf("%lf\n",d); return 0; }