In the printf() function of C language, %.1 represents the floating-point variable output format, specifying one digit after the decimal point.
The meaning of %.1 in C language
%.1 is in the printf() function in C language Commonly used format specifiers. It is used to specify the output format of floating point variables.
Detailed description:
Example:
<code class="c">#include <stdio.h> int main() { float num = 3.141592; printf("小数点后一位:%.1f\n", num); return 0; }</code>
Output:
<code>小数点后一位:3.1</code>
In the above example, the printf() function uses the %.1f format specification The symbol outputs the floating-point variable num to one decimal place. Therefore, the output is 3.1.
Note:
The above is the detailed content of What does %.1 mean in C language?. For more information, please follow other related articles on the PHP Chinese website!