Home > Back-end >  In the C language and when to use % d % f
In the C language and when to use % d % f

Time:03-26

% % d and f are formatted output, the output to the specified data type, "% d to output an integer value, % f said to output a floating point value, such as the following statement:
Int a=100
Float b=7.68
Printf (" a=% d ", a);//here will output a, a is an integer value, so use % d;
Printf (" b=% f ", b);//here to output b, b is floating point, so use % f,


Chase, shicheng cc Chen Lichen, founder of the science and technology

CodePudding user response:

Good, ask yourself the answer ah,,,

CodePudding user response:

Is this advertisement? Are binary data in the memory, using % d output is a value, use % f output is a value, although not the same, but the memory of the binary constant, because the floating-point and integer representation methods, namely, for the same binary number, the different symbols, such as and % f, % d its analytical method is different, so the result is not the same,
  • Related