c语言中打印浮点数

c语言中打印浮点数。

#include <stdio.h>

int main(void)
{
    float f = 100.0;
    double d = 1.0e2;
    long double ld = 1.0e2;
    
    printf("float: %f.\n", f);
    printf("float: %e.\n", f);
    printf("float: %E.\n", f);
    printf("float: %a.\n\n", f);
    
    printf("double: %f.\n", d);
    printf("double: %e.\n", d);
    printf("double: %E.\n", d);
    printf("double: %a.\n\n", d);
    
    printf("long double: %Lf.\n", ld);
    printf("long double: %Le.\n", ld);
    printf("long double: %La.\n", ld);
    
    
    return 0;
}

 

posted @ 2021-07-19 23:48  小鲨鱼2018  阅读(2257)  评论(0编辑  收藏  举报