0

can someone explain me what is the meaning of the number after the modulo (%)
EX. printf("the number is: %10.2f", number);
please help me define and understand the number after the % and give example, thanks!

4
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by thunderwolf07
0

In the case of %f, it's the field width and precision.

The field width specifies the minimum number of characters that will be printed. The field will be padded with whitespace if the value is smaller than the field width. If it's larger, nothing special happens.

The precision specifies the number of digits to print after the radix. At 2, if your variable is 1.2132, only 1.21 will be printed.

0

can someone explain me what is the meaning of the number after the modulo (%)
EX. printf("the number is: %10.2f", number);
please help me define and understand the number after the % and give example, thanks!

Hello, with %10.2 you specify the format in which your float number will be printed. Your number (including dot) will occupy 10 digits and decimal part will occupy 2 digits. I hope i helped..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.