?C
1
C
2
2.0
C
3
100123452 592121202121211 1 1 0 1 1
100128 94868381136
10012316 7 9 7 81610162161516121AF
C
4
0
459
45916
2816
116
0
(459)10=(1CB)16
1 C B
11
12
1
()
C
5
330
3
(1101001)2=(001,101,001)2=(151)8
(246)8=(010,100,110)2=(10100110)2
000 ~ 0
001 ~ 1
010 ~ 2
011 ~ 3
100 ~ 4
101 ~ 5
110 ~ 6
111 ~ 7
C
6
440
4
(11010101111101)2=(0011,0101,0111,1101)2=(357D)16
(4B9E)16=(0100,1011,1001,1110)2=(100101110011110)2
0000 ~ 0
0001 ~ 1
0010 ~ 2
0011 ~ 3
0100 ~ 4
0101 ~ 5
0110 ~ 6
0111 ~ 7
1000 ~ 8
1001 ~ 9
1010 ~ A
1011 ~ B
1100 ~ C
1101 ~ D
1110 ~ E
1111 ~ F
C
7
8
01
01234567
0
1
2
3
4
5
6
7
8
9
10 ……..
.
7
6
4
3
2
5
1
C
8
1
11
3
12
6
9
1
2
4
57
8
10
11
9-5=4
9+7=16=(14)12
——
C
9
+7 00000111 00000111 00000111
-7 10000111 11111000 11111001
+0 00000000 00000000 00000000
-0 10000000 11111111 00000000
01111111~
11111111
(-127~+127)
01111111~
10000000
(-127~+127)
01111111~
10000000
(-128~+127)
1
11111001
10000110
1 10000111=-7
C
10
void
typedef
char
enum
float
double
struct
union
short
long
int
1,
2,
3,
2.1
C
11
(signed)int 16 -32768~32767
(signed)short 16 -32768~32767
(signed)long 32 -2147483648~2147483647
16unsigned int 0~65535
32 0~4294967295unsigned long
unsigned short 16 0~65535
float 3
2
3.4e-38~3.4e38
double 6
4
1.7e-308~1.7e308
char 8 -128~127
unsigned char 8 0~255
:,IBM PC:
intunsigned int
C
12
sum Sum M.D.John day Date 3days
student_name #33 lotus_1_2_3
char a>b _above $123
< >
M.D.J 3days
#33
$123a>b
C
13
C #define PRICE 30
< >
(ch2_1.c)
#define PRICE 30
main()
{
int num,total;
num=10;
total=num*PRICE;
printf("total=%d",total);
}
total=300
C
14
~
~
~ ~ ~
12 12L30000 int
65536 long int
long int
0123 = ( )10
0x123 = ( )10
0Xff = ( )10
83
291
255
10
10
ff )10
C
15
C
aaa 16
.
<
\n
\v
\r
\a
\?
\ddd
\t
\b
\f
\\
\“
\xhh38 216
\101? -----------?A\012? -----------?\n?
\376? -----------\x61? -----------?a?
\60? -----------?0\483? ----------(?)
:
A?-------?\101?-------?\x41?--------65
——?——
————
aA\n\101?
(ch2_001.c,ch2_004.c)
main()
{
printf("\101 \x42 C\n");
printf("I say:\"How are you?\"\n");
printf("\\C Program\\\n");
printf("Turbo \'C\'");
}
()
A B C
Isay:”How are you?”
\C Program\
Turbo?C?
main()
{ printf(“Y\b=\n”);
}
=

C
17
“”
h e l l o \0”
a a \0a?,a”
\0
,char ch;
ch=“A”;;
C
18
…...
int a=1,b=-3,c;
a
b
c
2
2
2
…...
1
-3

1[2… n];
:,
int a,b,c;
float data;
:
int a=2,b,c=4;
float data=3.67;
char ch=?A?;
int x=1,y=1,z=1;
int x=y=z=1;
1
int student;
stadent=19; //Undefined symbol?stadent? in function main
2
float a,b,c;
c=a%b; //Illegal use of floating point in function main
main()
{ int a,b=2;
float data;
a=1;
data=(a+b)*1.2;
printf(“data=%f\n”,data);
}
main()
{ int a,b=2;
a=1;
float data;
data=(a+b)*1.2;
printf(“data=%f\n”,data);
}
C
19
~
1,float a;
a=111111.111; /* a=111111.1*/
2,double b;
b=111111.111; /* b=111111.111*/



C
20
/*ch2_003.c*/
#define PRICE 12.5
main()
{ int num=3;
float total;
char ch1,ch2=?D?;
total=num*PRICE;
ch1=ch2-?A?+?a?;
printf(“total=%f,ch1=%c\n”,total,ch1);
}
total=37.500000,ch1=d
C
21
2.3
C
22
double float
long
unsigned
int char,short
:
char ch;
int i;
float f;
double d;
ch/i + f*d - (f+i)
int
int
double
double
double
double
double
double
int
int
double
double
double
double
double
double
10+?a? +i*f - d/l
2 int i;
float f;
double d;
long l;
1
C
23
main()
{ float x;
int i;
x=3.6;
i=(int)x;
printf(“x=%f,i=%d”,x,i);
}
x=3.600000,i=3
C
24
C
2.4
C
25
C
26

5/2 =
-5/2.0 =
5%2 =
-5%2 =
1%10 =
5%1 =
5.5%2
2
-2.5
1
-1
1
0
(?)
C
27
j=3; k=++j;
j=3; k=j++;
j=3; printf(“%d”,++j);
j=3; printf(“%d”,j++);
a=3;b=5;c=(++a)*b;
a=3;b=5;c=(a++)*b;
C
28
,”,”
C
29
a+=3 a=a+3
x*=y+8 x=x*(y+8)
x%=3 x=x%3
C
30
,14
,float f;
int i;
i=10;
f=i;
f=10.0
int i;
i=2.56; //i=2;
C
31
,12
,
C
32
1,2,…… n
:
,15
n
for
a=3*5,a*4
a=3*5,a*4,a+5
x=(a=3,6*3)
x=a=3,6*a
a=1;b=2;c=3;
printf(“%d,%d,%d”,a,b,c);
printf(“%d,%d,%d”,(a,b,c),b,c);
//a=15,60
//a=15,20
//18x=18
//,18,x=3
//1,2,3
//3,2,3
:
/*ch2_6.c*/
#include <stdio.h>
main()
{ int x,y=7;
float z=4;
x=(y=y+6,y/z);
printf("x=%d\n",x);
}
x=3
C
33
< <= == >= > != <<=
>
>=
==
!=
6
7
10
int a=3,b=2,c=1,d,f;
a>b
(a>b)==c
b+c<a
d=a>b
f=a>b>c
//1
//1
//0
//d=1
//f=0
C
34
a=0; b=0.5; x=0.3;
a<=x<=b 0
5>2>7>8C
0
int i=1,j=7,a;
a=i+(j%4!=0);
a= 2
a?>0
A?>100
1
0
1
C
35
=” ==”
int a=0,b=1;
if(a=b)
printf(“a equal to b”);
else
printf(“a not equal to b”);
1.0/3.0*3.0==1.0
fabs(1.0/3.0*3.0-1.0)<1e-6
0
2
C
36
a b !a !b a&&b a||b
! && ||
1
C
37
! (2)
&& (11)
|| (12)
a<=x && x<=b
a>b&&x>y
a==b||x==y
!a||a>b

!,
&&,
||,
// (a<=x) && (x<=b)
//(a>b)&&(x>y)
//(a==b)||(x==y)
//(!a)||(a>b)
2
C
38
! (2)
&& (11)
|| (12)

!,
&&,
||,
a=4;b=5;
!a
a&&b
a||b
!a||b
4&&0||2
5>3&&2||8<4-!0
c?&&?d?
1
0
1
1
1
1
//(5>3)&&2||(8<(4-(!0))) 1
3
C
39
! (2)
&& (11)
|| (12)

!,
&&,
||,
< >
a&&b&&c //ab
ab c
a||b||c //ab
ab c
a=1;b=2;c=3;d=4;m=1;n=1;
(m=a>b)&&(n=c>d) //m=0,n=1
4
C
40
expr1? expr2,expr3
if
if (a>b)
printf(“%d”,a);
else
printf(“%d”,b);
printf(“%d”,a>b?a:b);
a+|b|
printf(“a+|b|=%d\n”,b>0?a+b:a-b);
expr1
expr2 expr3
0 =0
(a==b)Y?:?N?
(x%2==1)?1:0
(x>=0)?x:-x
(c>=?a? && c<=?z?)?c-?a?+?A?:c
x>0?1:(x<0?-1:0)
,13
a>b?a:c>d?c:d? a>b?a:(c>d?c:d)
expr1expr2expr3
xa?:?b? //x=0,b?; x?0,a?
x>y?1:1.5 //x>y,1.0; x<y,1.5
C
41
01 11 11 11 11 11 11 11int,32767
10 00 00 00 00 00 00 00,-32768
11 11 11 11 11 11 11 11unsigned int,65535
00 00 00 00 00 00 00 00,0
1
C
42
o101102…
0~9
10
0~1
2
o2122…
0~7
8
o8182…
0~9,A~F,a~f
16
o161162…
4956= 4?103+9?102 +5?101+6?10o1011 1?23+0?22 +1?21+?2o81AE 8 6 1 6 10?161+14?16o275 8 2 8 7 8 5 8o
2