Home / Programs / Double format specifier : %f, %e or %E Example Program
Programming Example

Double format specifier : %f, %e or %E Example Program

👁 1,231 Views
💻 Practical Program
📘 Step by Step Learning
Double format specifier : %f, %e or %E Example Program

Program Code

#include <stdio.h> 
int main() 
{ 
    float a = 12.67; 
    printf("%f\n", a); 
    printf("%e\n", a); 
    return 0; 
}

Output

12.670000
1.267000e+01

Explanation

The %f format specifier is implemented for representing fractional values. This is implemented within printf() function for printing the fractional or floating value stored in the variable. Whenever you need to print any fractional or floating data, you have to use %f format specifier.

Syntax:
printf("%f", <variable name>);

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.