🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to C Notes
Topic #18

Decimal Precision


Set Decimal Precision

You have probably already noticed that if you print a floating point number, the output will show many digits after the decimal point:

Example

  float myFloatNum = 3.5;
double myDoubleNum = 19.99;

  printf("%f\n", myFloatNum);
  // Outputs 3.500000
printf("%lf", myDoubleNum); // Outputs
  19.990000

If you want to remove the extra zeros (set decimal precision), you can use a dot (.) followed by a number that specifies how many digits that should be shown after the decimal point:

Example

float myFloatNum = 3.5;

printf("%f\n", myFloatNum);   // Default will show 6 digits after the decimal point
printf("%.1f\n",
myFloatNum); // Only show 1 digit
printf("%.2f\n", myFloatNum); // Only
show 2 digits
printf("%.4f", myFloatNum);   // Only show 4 digits

Want to go beyond the notes?

Join CodingNow 2.0's C course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Decimal Precision – FAQs

Quick answers about learning Decimal Precision in C.

This free note from CodingNow 2.0 explains Decimal Precision in C — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every C topic on CodingNow 2.0, including Decimal Precision, is 100% free with no signup required.
With focused practice, most students grasp Decimal Precision in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now