Q: Why in my c program when I use double it only puts out 0, but when I instead use float it works? When I use float, like this:
#include <stdio.h>

int main()
{
    float g;
    float f;

    scanf("%f", &f);
    g = f / .5;
    printf("%f", g);
    return 0;
}

and enter 2 I get back 4.000. When instead in the place of float I use double the result is always 0.000. Why is this am I missing something?

A: #include <stdio.h>

int main()
{
    double g;
    double f;

    scanf("%lf", &f);
    g = f / .5;
    printf("%lf", g);
    return 0;
}

You need to use the format specifier specifically for doubles (%lf) here.
See format string specifications for more information about different format specifiers.

A: As, Scanf not reading in double,
You lied to the compiler: when scanning, %f says you supply a pointer to float. But you provided a pointer to double.
To fix, either use %lf or declare input as float.
Note that there is an asymmetry with printf formats, which uses %f for both float and double arguments. This works because printf arguments are promoted to double (and are not pointers).
