/* Formatting.c (c) Kari Laitinen http://www.naturalprogramming.com/ 2013-11-19 File created. 2013-11-19 Last modification. This program shows how format specifiers; such as %9d, can be used when function printf() is called. To find examples about formatting floating-point values, see programs Miles.c and Distance.c */ #include int main() { int some_integer = 123456 ; printf( "\n 12345678901234567890 \n" ) ; printf( "\n %9d right justified", some_integer ) ; printf( "\n %-9d left justified", some_integer ) ; printf( "\n %9X right hexadecimal", some_integer ) ; printf( "\n %-9X left hexadecimal", some_integer ) ; printf( "\n %d no printing field", some_integer ) ; printf( "\n %X hexadecimal uppercase", some_integer ) ; printf( "\n %x hexadecimal lowercase", some_integer ) ; printf( "\n %012d leading zeroes", some_integer ) ; printf( "\n %012X hexadecimal", some_integer ) ; printf( "\n" ) ; char another_text_to_print[] = "SOME TEXT" ; printf( "\n %s is a string.", another_text_to_print ) ; char some_character = 'K' ; printf( "\n %c is a character.\n", some_character ) ; }