/* * formatint1.c - format field width, and padding with zeros */ #include int main(void) { // Printing integers right justified with a field width of 10 chars spaces printf("Right Justified 10 chars field\n"); printf("12345678901234567890<--- column or character numbers.\n"); printf("%10.4d%10.4d\n", 1,7); printf("%10.4d%10.4d\n", 12,78); printf("%10.4d%10.4d\n", 123,789); printf("%10.4d%10.4d\n\n\n", 1234,7890); // printing integers left justified with a field width of 10 characters printf("Left Justified 10 chars field\n"); printf("12345678901234567890<--- column or character numbers.\n"); printf("%-10.4d%-10.4d\n", 1,7); printf("%-10.4d%-10.4d\n", 12,78); printf("%-10.4d%-10.4d\n", 123,789); printf("%-10.4d%-10.4d\n", 1234,7890); return 0; }