0

Why here taking %6.2f instead of %f? In some times to taking %5d makes me more confusing in some texts......

#include <stdio.h> int main() { float purchases[3] = {10.99, 14.25, 90.50}; float total = 0; int k; /* total the purchases */ for (k = 0; k < 3; k++) { total += purchases[k]; } printf("Purchases total is %6.2f\n", total); /* Output: Purchases total is 115.74 */ return 0; }

2nd Mar 2019, 2:41 AM
V Chandu
V Chandu - avatar
1 Resposta
+ 6
The 6 after the % means to print a minimum of 6 characters, and the 2 after %6. means 2 decimal places.
2nd Mar 2019, 3:21 AM
Rowsej
Rowsej - avatar