#include <stdio.h>
int main(void)
{
printf("Characters: %c %c \n", 'a', 98);
printf("Signed decimal integer: %d %i \n", 1234, 9763);
printf("Preceding with blanks: %10d \n", 1966);
printf("Preceding with zeros: %010d \n", 1966);
printf("Unsigned decimal integer: %u\n", 30000);
printf("Unsigned octal: %o\n", 600);
printf("Unsigned hexadecimal integer: %x %X\n", 0x13f, 0x13f);
printf("Decimal floating point: %f\n", 3.14f);
printf("Floats: %4.2f %+.0e %E \n", 3.14159, 3.14159, 3.14159);
printf("Scientific notation: %e %E\n", 3.783e+2, 3.783e+2);
printf("string: %s\n", "abcde string");
int n = 10;
int *p = &n;
printf("Pointer address: %p\n", p);
printf("The shortest representation: %%e or %%f: %g\n", 873.2357);
printf("The shortest representation: %%E or %%F: %G\n", 873.2357);
printf("Decimals: %d %ld\n", 1977, 650000L);
printf("Different radices: %d %x %o %#x %#o \n", 100, 100, 100, 100, 100);
printf("Width trick: %*d \n", 5, 10);
return 0;
}
/*
run:
Characters: a b
Signed decimal integer: 1234 9763
Preceding with blanks: 1966
Preceding with zeros: 0000001966
Unsigned decimal integer: 30000
Unsigned octal: 1130
Unsigned hexadecimal integer: 13f 13F
Decimal floating point: 3.140000
Floats: 3.14 +3e+000 3.141590E+000
Scientific notation: 3.783000e+002 3.783000E+002
string: abcde string
Pointer address: 000000000022FE44
The shortest representation: %e or %f: 873.236
The shortest representation: %E or %F: 873.236
Decimals: 1977 650000
Different radices: 100 64 144 0x64 0144
Width trick: 10
*/