← The C Language
Lesson 7 of 77 · 5 XP
Warm-up: a decimal number warm-up
Theory and problem statement
Machine translation, not yet reviewed by a native speaker.
Decimal numbers are stored in double. You read them with %lf and print them with %f. The number of digits after the point goes between % and f:
double x;
scanf("%lf", &x);
printf("%.2f\n", x); // two digits after the point: 3.14159 → 3.14
Task. Read a decimal number and print it with two digits after the point.
Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.