5. Output format
There are three output formats that are normally used
1.%md
It is possible to make int-types with less than m bits to rightaligned output, where the high digit is filled with a space and remains unchanged if itself exceeds m digits
-
int a = 123;
-
printf("%5d\n",a);
-
-
// Output
-
123
2.%0md
Unlike md, when the variable is less than m, it is preceded by enough zeros instead of spaces.
-
int a = 123;
-
printf("%5d\n",a);
-
-
// Output
-
00123
3.%.mf
It is possible to have floating point numbers retain m bits of output, taking the principle of rounding up to five into two
-
-
double d1 = 12.3456;
-
printf("%.3f,d1)
-
// Output
-
12.346