C/C++ Arena

Step 3 of 5

Reading doubles

Here's a quirk: printf uses %f for a double, but scanf needs %lf ("long float") to read into a double.

double price;
scanf("%lf", &price);
printf("%.2f\n", price);

Your turn: read a temperature in Celsius and print it in Fahrenheit with one decimal. The formula is f = c * 9 / 5 + 32.

Input 100 prints 212.0. Input 36.6 prints 97.9.

Previous: Several values at once Next: Characters and words