C语言:强制类型转换

#include <stdio.h>
//强制类型转换
//写法:(类型标识符)变量;(类型标识符)常量;(类型标识符)(表达式);三种格式
 
main()
{
    float a=7.5f;
    long b=100L;
    printf("%d,%d\n",sizeof(a),sizeof(b));
    printf("%f,%d\n",a,b);
    printf("%d,%d\n",a,b);
    printf("%f\n",1); 
    printf("%f\n",(1+2*2+3));
    printf("%d\n",1+3/2); 
    printf("%f\n",1/3*3);
    printf("%d\n",1/3*3);
    printf("%lf\n",132/8);
    printf("第%d行的结果:%lf\n",__LINE__,(float)(132)/8);
    printf("第%d行的结果:%f\n",__LINE__,(float)(132)/8);
    getchar();
 }

 

posted @ 2021-04-27 06:41  myrj  阅读(321)  评论(0编辑  收藏  举报