C
:
763838
36
C
1.
2.
3.
1C
2
3
1
1.1 C
1.2
1.3 C
1.4 Turbo C

01
1.1 C
1
1,C
2,CD.M.ritchie1972BUNIX
3,1977CCUNIXUNIX
4,1983ANSICANSI CC
2C
C
1
2
3
4
5
3,C9C
C
1.1 Hello world!
#include <stdio.h> /**/
void main( ) /**/
{
printf(“Hello,world!\n”); /**/
}
#include
voidmain
Cmain{ }
printfC
\nC
C
1.2
main()
{
int a,b,sum; /**/
a=123;b=456; /*C*/
sum=a+b; /*ab,sum*/
printf(“sum is %d\n”,sum);
}
/*…*/
int
%dsum
C
1.3
int max(int x,int y) /*max*/
{int z;
if(x>y)z=x; /*,x>y,xz*/
else z=y; /*yz*/
return z; /*zmain*/
}
main() /**/
{int a,b,c; /**/
scanf(“%d,%d”,&a,&b); /*ab*/
c=max(a,b); /*maxc*/
printf(“max=%d”,c); /*c*/
}
1.2
1.2.1
main()main()
main()
{ printf(“This is a C program.\n”);
}
This is a C program.
1.
main()
2.C main()
main()
main()
1.2.2
main()
[ ] ()
{
}
1.
[,2…… ]
max()1-1
↓ ↓ ↓
int max ( int x,int y )
1-1
3.
1
2
1-2[1.2]main()
/*main()*/
main()
{ int num1,num2;
printf(“Input the first integer number:,);
scanf(“%d”,&num1);
printf(“Input the second integer number:”);
scanf(“%d”,&num2);
printf(“max=%d\n”,max(num1,num2));
}
1-2
3.
1
int max
main()
{ int x,y; /*2xy*/
x=3; /*3x*/
y=6; /*6y*/
int max; /*
x=3;” y=6;”*/
max=x>y?x:y;
printf(“max=%d\n”,max);
}
2
1.2.3
1.
2.11
main()
……
main()
{ int num1,num2;
printf(“Input the first integer number:,); scanf(“%d”,&num1);
printf(“Input the second integer number:”); scanf(“%d”,&num2);
printf(“max=%d\n”,max(num1,num2));
}
3.
C /* …… */
[1.1][1.2] /*” */”
1 /*” */” /” * * /”
21
311
4
[Return]
main()
{int a,b,c,max; /*max*/
scanf(“%d,%d,%d”,&a,&b,&c); /**/
max=a; /*amax*/
if(max<b) max=b; /*maxbmaxab*/
if(max<c) max=c; /*abc*/
printf(“max = %d”,max); /**/
}
3
main()
{
float a,b,c,ave;
a=3.5;
b=4.6;
c=7.9;
ave=(a+b+c)/3;
printf(“ave=%f\n",ave);
}
1.3 C
1.3.1 C
1.
1
if() else,switch()
2
dowhile(),for(),while(),break,continue
3
goto,return
2,
printf("This is a C function statement.");
3.
num=5” num=5;”
4.
5.
1
main()
{ ……
{…… } /**/
……
}
1
2
1.3.2
C32
112 char,double,enum,float,int,long,short,signed,struct,
union,unsigned,void
212 break,case,continue,default,do,else,for,goto,if,return,
switch,while
34auto,extern,register,static
44const,sizeof,typedef,volatile
[Return]
1.4 Turbo C 2.0
1.
2.TC
3.
4.──
5.
6.
1.
urbo
1TCTC
2
32
4
52
6TC
[Return]
2.TC
1Turbo C tc ←┘
Turbo CFile
EditMessage
Line 1 Col 1
Insert
d,NONAME.C NONAME.C”
7Num Lock NUM”
2
1F10
2
3
F10Esc
3Turbo C
TC
1File | QuitFileQuit
2Alt+“X”Alt
[Return]
3.
1
2
.
3
F2File | Save
F1
──PageDown──PageUp
──Esc
──Alt+F1
──F1F1
──^F1^F1
^” Ctrl”^FnCtrl+Fn
[Return]
4.──
Compile | Make EXE File F9TC
Compiling” Error,Press any key”
Message” Edit”
[Return]
5.
1
Run | Run^F9
TC
2
Run | User Screen Alt+F5
[Return]
6.
File | New
NONAME.C not saved,Save? Y/N
2
1
<d:><path>\NONAME.C
2
[Return]