c语言的基本数据类型与表达式,C 02 c语言的基本数据类型与表达式
*
*
Data Type
*
charintlongshortfloatdoubleenum[ ]structunion*vodi
2.1C #include /* ab ab*/
int Add(int a, int b){return (a + b);}
/**/main(){int x, y, sum = 0;printf("Input two integers:");scanf("%d%d", &x, &y); /*xy*/sum = Add(x, y); /*Addxy*/printf("sum = %d\n", sum); /*xy*/}
C Keyword Cint,return Identifiermain,printf Add, x, y Operator342 Separator /
C {} /**/ DataVariableConstant
variablenamevariable_namevariableName
Windows UNIX
Unix/Linuxvariable_nameWindowsVariableNameJavavariableName
int, float, for, while, iffori, j, k
Unix/Linuxvariable_nameWindowsVariableNameJavavariableName
b, B, KB, MB, GB, TBbitByteKilobyte(KB) KMegabyte(MB)Gigabyte(GB)GTerabyte(TB)T
10241000810
b, B, KB, MB, GB, TB1 TB == 1,024 GB1 GB == 1,024 MB1 MB == 1,024 KB1 KB == 1,024 B1 B == 8 b
10241000810
b, B, KB, MB, GB, TB01ASCIIP427DASCIIGB0~255
UNICODE
*
12-10000012=1*81+2*80=10(0x0x12=1*161+2*160=18(0~7
0180~9a~fA~F10~15
0x1e
*
:intshortlongunsignedsigned
Turbo Cshort2int2long4
short16-3276832767unsigned short16065535int16-3276832767unsigned int16065535long32-21474836482147483647unsigned long3204294967295
OverflowCTC2int-32768~32767-3276832767
typeoverflow.c
Overflow6432
1+2+3+1!+2!+3!+13+23+33+
*
3.44.00.3 + e(E) + 12.5e-612.510-60. .0 . eE6E0.2 e5
float43.410-38 ~ 3.410387double81.710-308 ~ 1.71030815
*
1A1?\
\n\\b\t\r\v\f\ddd13\\\xhh12
*SHANGHAIAbcdeFGHijkHow are you
char1ASCII0127128
\ \\ \ aa
*
*
120 -100001200720xFFFF0x1e0x28AF0xED4120L200L09912f0xg48EA 3.14-3.15.12E-6019.51e-082.1E10.2E-66.4E4.8E9 'a''#''\n''\101'''changsha'''\''\p''''ab'''+++\\?ab''
*
#define
#define MAX 1000#define MIX 10#define PI 3.1415926
*
* 1[,2,3];
int a,b,c;int a; int b; int c;float m,n;char s,t;intcharfloatC
*
int a,b,c;a=2; b=5; c=12;int a=2,b=5,c=12;int a=5; a=12;int a,b,c;a=b=c=3;int a=b=c=3;
*
+ - * / %> < == >= ~ | &= ? :,* &sizeof ->[ ]
*+-*/%
5%3=_____6.2%3=_____%5/3=_____xdoubleyintx+y_____double6+A=_____
*( )*/%+--
int a=8,b=6,c=5,y;y=-a-b*c+a/c;y=_____-37
* float a=2.0; int b=6,c=3;a*b/c-1.5 +a+fabs(-5)12.0/354.0 - 1.52.5 + 97(int)99.5 + 5104.5(double)
**++--
11++i--iii1i++i--ii1int x=3,y;y=x++;
y=_____int x=3,y;y=++x;
y=_____34int x=3,y;y=-x++;
y=________________-(x++)(-x)++
*=
int a,b=5,m=7,n=8;a=3;a=b;a=m+n;
*=
x+=5; x=x+5;x*=y+8; x%=3; x-=y;
a12a+=a-=a*a_____x=x*(y+8);x=x%3;x=x-y;-264
*
>==
*
!&&||! &&||10
!&&||
*1,2
int x,y=5;x=(y=y+6,y=y/3);x_____
1221,2,,n
3
*?:
int x=3,y=5,z;z=x>y?100:200;z_____
11213200
*
sizeof()sizeof()int x=5;y=sizeof(x);y_____z=sizeof(int);z_____22
*
() ()int x=6,y=4;x/y=_____int x=6,y=4;(float) (x/y)=__________int x=6,y=4;(float) x/y=__________11.0000001.500000
*8801(int)long intlong int1601(unsigned int)long intlong int160
Unix/Linuxvariable_nameWindowsVariableNameJavavariableNameUnix/Linuxvariable_nameWindowsVariableNameJavavariableName1024100081010241000810UNICODE