Displaying Floating-Point Data Types with printf() - C Data Type

C examples for Data Type:Introduction

Introduction

To display floating-point numbers, use the %f conversion specifier demonstrated next.

Demo Code

#include <stdio.h>

int main()/*from   www . j a  v  a 2 s . co m*/
{
    printf("%f", 55.55); 
    return 0;
}

Result

The following example uses the %f conversion specifier to print the contents of a floating point variable:

Demo Code

#include <stdio.h>

int main(){/*from  w w w .j  a v a 2 s  .com*/
    float result; 
    
    result = 3.123456; 
    
    printf("The value of result is %f", result); 
    return 0;
}

Result


Related Tutorials