You can do it like this:

double a;
scanf("%lf", &a);
printf("%.1lf", a);

If you want to round off a double to only N decimal place, you can use %.Nlf instead of %.1lf .

Answer from gsm on Stack Overflow
🌐
Quora
quora.com › How-do-I-round-a-float-to-1-decimal-place-after-a-division-in-C
How to round a float to 1 decimal place after a division in C++ - Quora
Answer (1 of 5): I usually multiply by 10, cast to an int, then cast back to a float, then divide by ten. Casting to int cuts off everything below 1, but since we've just multiplied by 10, we're cutting off eveything below 1.0 It looks like this: float v = 12.34; v = ((float )((int)(v * 10)))...
🌐
Quora
quora.com › How-do-you-handle-the-rounding-of-decimal-places-in-C-C-float-rounding-development
How to handle the rounding of decimal places in C (C, float, rounding, development) - Quora
If this number is 5 or greater, round up. If it is 4 or lower, round down. The decimal point in the middle doesn't change anything. For example, if you needed to round the example number from earlier (12.9889) to the nearest whole number, you'd start by looking at the ones place: 1.9889.
🌐
OpenGenus
iq.opengenus.org › rounding-and-truncating-numbers-in-c
Rounding and Truncating numbers using math.h in C
November 10, 2019 - It takes a floating value as argument and rounds the decimal part of it. It returns value in floating type format. If we pass float number as an argument, the syntax is: ... #include <stdio.h> #include <math.h> int main() { printf("roundf(+2.311) gives = %+.1f\n", roundf(2.311)); //here %+.1f is used to print only one place after decimal }
🌐
Arduino Forum
forum.arduino.cc › projects › programming
Round with one decimal point - Programming - Arduino Forum
April 28, 2022 - I have problem. SHT temperature is 24.37 and rouding temp = 24.37 and it should have been 24.3. Why does it still show two decimal places? I have code: float temp = (sht.getTemperature() * 10) / 10; float temp = (raw * 10) / 10;
🌐
Reddit
reddit.com › r/c_programming › decimal places
r/C_Programming on Reddit: Decimal places
September 15, 2018 -

Can I create a variable and set it to a specific decimal place? For example "float z to 5 dp" where z would be recorded to 5 dp for the rest of the program

🌐
W3Schools
w3schools.com › c › c_data_types_dec.php
C Data Types Decimal Precision
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: 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 Try it Yourself »
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › cplusplus-program-to-round-a-number-to-n-decimal-places
C++ Program to Round a Number to n Decimal Places
In our example, there is a negative number - 45.69 here after rounding it off, it is turning it into -46 which is smaller than this. So round() method is not like floor() or ceil(). Representing floating point numbers up to n decimal places has few approaches when we are writing code in C++. ...
🌐
Scaler
scaler.com › home › topics › c round() function
C round() Function - Scaler Topics
March 27, 2024 - The syntax of the round function is very simple, it just accepts one argument which can be float, int, or double, and it returns the integer by rounding it off to the accurate value. Its generic syntax is as follows · Here the num variable can be of float, or double type and the roundedValue will be an integer returned by the round() function and the roundedValue will not contain any decimal part.
🌐
Unreal Engine
forums.unrealengine.com › development › programming & scripting › blueprint
Need to round float to one decimal point. Why is it so difficult? - Blueprint - Epic Developer Community Forums
I just need to round a float to one decimal point but nothing is working. The most common response is to multiply my number by 10, floor it into an integer, then divide it by 10 again to turn it back into a float. It doesn’t work. I keep ending up with results like 2.100002 or 8.699998 Numbers that end in .0 or .5 work properly but everything else is off by .000002 and I can’t figure out why.
Published   April 7, 2023
🌐
22web
randy.22web.org › classes › cop2000.c › rounding.html
How to Round a Number in a C Program
March 1, 2005 - This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support
🌐
Reddit
reddit.com › r/c_programming › rounding in c
r/C_Programming on Reddit: Rounding in C
May 8, 2024 -

I have a question when it comes to rounding in C. Does it round up or down at .5? If it does round up, then does that mean that the smallest value of k in the code below can only be 1?

 int main()
{
    int k = 13;
    int i;
    for (i = 0; i < 8; i++) {
        printf("%d", (k%2));
        k >>= 1;
    }
    printf("%n");
}

🌐
Simplilearn
simplilearn.com › home › resources › software development › setprecision() function in c++ with examples
setprecision() Function in C++ with Examples
July 31, 2025 - Master C++ setprecision() easily with concise explanations and examples. Control floating-point precision for optimal output formatting. Boost your skills!
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
GeeksforGeeks
geeksforgeeks.org › c language › g-fact-41-setting-decimal-precision-in-c
Setting decimal precision in C - GeeksforGeeks
January 10, 2025 - // C program to set precision in floating point numbers // using format specifier #include<stdio.h> int main() { float num = 5.48958123; // 4 digits after the decimal point printf("%0.4f", num); return 0; }
🌐
Qt Forum
forum.qt.io › home › qt development › general and desktop › rounding a real number to nth place of decimal
Rounding a real number to nth place of decimal | Qt Forum
March 2, 2022 - I want to round the real value to specific decimal places because I don't want to store other digits in my database. Use cases can be any real number like round(54.3467,2) = 54.35 , round(5.842) = 6 , round(8.54123,4)=8.5412 ..so on