21st Nov 2019, 5:01 AM
THE CRAZY ONE ✌
THE CRAZY ONE ✌ - avatar
2 Answers
+ 7
In %x.y x is minimum number of characters including whole part or integer number part, point and decimal part y number of characters of decimal part If total number of characters are less than x, it fills with blank spaces at the left side of number With -ve sign it fills blank spaces at the right side of the number Example: printf("'%3.2f'",3.14159); ' 3.14' printf("'%5.8f'",3.14159); ' 3.14159' printf("'%-8.5f'",3.14159); '3.14159' printf("'%8.5f'",3.14159); ' 3.14159' It rounds 3.14159 to nearest to the define places. The output is 3.14 when fraction part is of 2 place round digit %8.5f is right-aligned, %-8.5f is left-aligned All positive will be left aligned and all negative will be right aligned means when positive on left side blank places will be increased to the defined number format specifier and when negative format specifier the right side will have blank spaces or zero which is added at right side ex:- printf("'%-8.5f'",3.2659); so at right side one zero will be added 3.26590
21st Nov 2019, 5:23 AM
GAWEN STEASY
GAWEN STEASY - avatar
0
Thanks Gawen
22nd Nov 2019, 3:42 PM
THE CRAZY ONE ✌
THE CRAZY ONE ✌ - avatar