The C Programming language Chapter 1 An Overview of C 1.2 The feature of C C is terse, it has fewer keywords C has a lot of operators and data types() C is structured and modular. C is the basis for C++ and java C is portable Code written on one machine can be easily moved to another
w 1.2 The feature of C – C is terse , it has fewer keywords –C has a lot of operators and data types – C is structured and modular. – C is the basis for C++ and Java – C is portable.Code written on one machine can be easily moved to another. < > > > > > The C Programming Language Chapter 1 An Overview of C
The C Programming language Chapter 1 An Overview of C 32 keywords:(由系统定义,不能重作其它定义) auto break case char const continue default do double else enum extern float for goto int long register return eYes short signed sizeof static struct switch typedef unsigned union void volatile while
32 keywords :( auto break case char const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef unsigned union void volatile while < The C Programming Language Chapter 1 An Overview of C
The C Programming language Chapter 1 An Overview of C 34 operators(运算待): Arithmetic(算术) operators: % + Relational(关系) operators:<< Logical(逻辑) operators:!& Bitwise(iz) operators :< > & Assighment(赋值) operators: Conditiona1(条件) operators: SY8 Comma(逗号) operators:, Address(地址) operators *k Sizeof(求字节数) operators: sizeof Casts(强制类型转换):(type-name) Structure member(分量) operators Subscript(下标) operators:[ others
34 operators(运算符): Arithmetic(算术) operators:+ - * / % ++ -- Relational(关系) operators :< <= == > >= != Logical(逻辑) operators :! && || Bitwise(位) operators :<< >> ~ | ^ & Assighment(赋值) operators : = += -= Conditional(条件) operators : ? : Comma(逗号) operators : , Address(地址) operators :* & Sizeof (求字节数) operators: sizeof Casts(强制类型转换):(type-name) Structure member(分量) operators : . -> Subscript(下标) operators :[ ] others :( ) - < The C Programming Language Chapter 1 An Overview of C
The C Programming language Chapter 1 An Overview of C 1.3 The pattern of a c program Exampl 1.1 the first c program Hello, World! /*example1. 1 The first C Program*/ notation include <stdio.h> Include information main( about standard library define a function named main printf(" Hello, World!") statement output: Hello, World!
1.3 The pattern of a C program Exampl 1.1 the first c program Hello,World! /* example1.1 The first C Program*/ #include <stdio.h> main() { printf(“Hello,World!”); } > notation Include information about standard library define a function named main statement output: Hello,World! The C Programming Language Chapter 1 An Overview of C
The c Programming language Chapter 1 An Overview of c expl. 2/* example1.1 calculate include <stdio.h> 损星》 a and b*/ This is the main program maino 函数 i int a, b, sum; 注释 a=10 b=24 sum=add(a, b) 语句 printf( sum/od\n", sum) / Thisfunction calculates the sum of x andy * int add(int x, int y) I int z Z=X+y 运行结果 return(z); sum=34
exp1.2 /* example1.1 calculate the sum of a and b*/ #include <stdio.h> /* This is the main program */ main() { int a,b,sum; a=10; b=24; sum=add(a,b); printf(”sum= %d\n" ,sum); } /* This function calculates the sum of x and y */ int add(int x,int y) { int z; z=x+y; return(z); } 运行结果: sum=34 函数 语句 预处理命令 注释 > The C Programming Language Chapter 1 An Overview of C