-
Notifications
You must be signed in to change notification settings - Fork 0
/
program15-1.c
58 lines (48 loc) · 1.5 KB
/
program15-1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Program to illustrate various printf() formats
#include <stdio.h>
int main(void)
{
char c = 'X';
char s[] = "abcdefghijklmnopqrstuvwxyz";
int i = 425;
short int j = 17;
unsigned int u = 0xf179U;
long int l = 75000L;
long long int L = 0x1234567812345678LL;
float f = 12.978F;
double d = -97.4583;
char *cp = &c;
int *ip = &i;
int c1, c2;
printf("Integers:\n");
printf("%i %o %x %u\n", i, i, i, i);
printf("%x %X %#x %#X\n", i, i, i, i);
printf("%+i % i %07i %.7i\n", i, i, i, i);
printf("%i %o %x %u\n", j, j, j, j);
printf("%i %o %x %u\n", u, u, u, u);
printf("%ld %lo %lx %lu\n", l, l, l, l);
printf("%lli %llo %llx %llu\n", L, L, L, L);
printf("\nFloats and Doubles:\n");
printf("%f %e %g\n", f, f, f);
printf("%.2f %.2e\n", f, f);
printf("%.0f %.0e\n", f, f);
printf("%7.2f %7.2e\n", f, f);
printf("%f %e %g\n", d, d, d);
printf("%.*f\n", 3, d);
printf("%*.*f\n", 8, 2, d);
printf("\nCharacters:\n");
printf("%c\n", c);
printf("%3c%3c\n", c, c);
printf("%x\n", c);
printf("\nStrings:\n");
printf("%s\n", s);
printf("%.5s\n", s);
printf("%30s\n", s);
printf("%20.5s\n", s);
printf("%-20.5s\n", s);
printf("\nPointers:\n");
printf("%p %p\n\n", ip, cp);
printf("This%n is fun.%n\n", &c1, &c2);
printf("c1 = %i, c2 = %i\n", c1, c2);
return 0;
}