<p>Why is it that <code>scanf()</code> needs the <code>l</code> in "<code>%lf</code>" when reading a <code>double</code>, when <code>printf()</code> can use "<code>%f</code>" regardless of whether its argument is a <code>double</code> or a <code>float</code>?</p>

<p>Example code:</p>

<pre><code>double d;
scanf("%lf", &amp;d);
printf("%f", d);
</code></pre>

Because C will promote floats to doubles for functions that take variable arguments. Pointers aren't promoted to anything, so you should be using
```
%lf
```
,
```
%lg
```
or
```
%le
```
(or
```
%la
```
in C99) to read in doubles.