Using %f to print an integer variable

Viewed 11040

The output of the following c program is: 0.000000

Is there a logic behind the output or is the answer compiler dependent or I am just getting a garbage value?

#include<stdio.h>

int main()
{
    int x=10;
    printf("%f", x);
    return 0;
}

PS:- I know that to try to print an integer value using %f is stupid. I am just asking this from a theoretical point of view.

6 Answers
Related