0
What is the use of first digit in format specifier?
printf("pi=%3.2f", 3.1456) Here if 3 is the width, I gave 3124.1456 as the input. But I got the answer as itself. It didn't cut off 4.
8 Answers
+ 5
The first digit gives the overall *minimal* width including dot that your number is supposed to occupy. If it's longer, you just don't see any effect. Change the number to 10 and there'll be a whitespace gap.
If you don't want that, just write:
%.2
+ 3
10 in your format-specifier!
%10.2f
First number is total minimal width, second number is digits after the dot.
+ 2
I have explained that in the first post. Please try what I just wrote and see if you get it!
+ 2
Because 10 is not a float. That's a different error.
+ 1
Do you mean it is the number of total characters. But when I gave 10 why didn't it give 10.00. It just gave 0.00
+ 1
Thanks a lot brother. I got you
đđ
0
I gave 10, I got the answer as 0.00. I still don't understand what happens. Pls explain me.
0
What is minimal width?