中国高校课件下载中心 》 教学资源 》 大学文库

《C程序设计语言》课程PPT教学课件(讲稿)第一章 An Overview of C(1.2)The feature of C

文档信息
资源类别:文库
文档格式:PPT
文档页数:56
文件大小:0.98MB
团购合买:点击进入团购
内容简介
Chapter An Overview of C 1.2 The feature of C -Cis terse, it has fewer keywords - has lot of operators and data types> - is structured and modular. -C is the basis for C++ and Java - is portable. Code written on one machine can be easily moved to another.
刷新页面文档预览

1 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 VBS C is portable Code written on one machine can be easily moved to another

 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

1 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 if int long register return 682 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: & Assighment(赋值) operators:= Conditiona1(条件) operators:?: 冷coma逗号) 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 Include information about standard library main( define a function named main ev)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 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 exp1. 2 example 1.1 calculate a and b include x This is the main program maino 函数 i int a, b, sum 注释 a=10 b=24; sum=adda, b); 语句 VBS printf( sum/odn, sum) / This function calculates the sum of x and y * int add(int X, int y) Z=X+y 运行结果 return (z) sum=34

exp1.2 /* example1.1 calculate the sum of a and b*/ #include /* 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

The C Programming Language Chapter 1 An Overview of C 格式特点 习惯用小写字母,大小写敏感 不使用行号,无程序行概念 可使用空行和空格 main( 常用锯齿形书写格式 int 1, j, sum; sum=0 for(i=1;i<10;i++) 优秀程序员的素质之一 使用TAB缩进 for(j=1;<10;j++) 仆对齐 有足够的注释 sum+=l"I 有合适的空行 printf(“%dⅦn”,sum);

– 格式特点 • 习惯用小写字母,大小写敏感 • 不使用行号,无程序行概念 • 可使用空行和空格 • 常用锯齿形书写格式 main( ) { ………………. ……………… ………….. ………….. ……… ………. …………… ……………. ………………. ……………….. } main( ) { int i , j , sum; sum=0; for(i=1; i<10;i++) { for(j=1;j<10;j++) { sum+=i*j ; } } printf(“%d\n”,sum); } 优秀程序员的素质之一:  使用TAB缩进  {}对齐  有足够的注释  有合适的空行 The C Programming Language Chapter 1 An Overview of C

The C Programming Language Chapter 1 An Overview of C 结构特点 函数与主函数 程序由一个或多个函数组成 必须有且只能有一个主函数main0 程序执行从main开始,在main中结束,其它函数通过嵌 套调用得以执行。 程序语句 VBS C程序由语句组成 非法 用“;”作为语句终止符 注释例:/= TThis is the main/ of example.1* 不产生编译代码 编译预处理命令

– 结构特点 • 函数与主函数 – 程序由一个或多个函数组成 – 必须有且只能有一个主函数main() – 程序执行从main开始,在main中结束,其它函数通过嵌 套调用得以执行。 • 程序语句 – C程序由语句组成 – 用“;”作为语句终止符 • 注释 – /* */为注释,不能嵌套 – 不产生编译代码 例: /*This is the main /* of example1.1*/ */ 非法 编译预处理命令 The C Programming Language Chapter 1 An Overview of C

The C Programming language Chapter 1 An Overview of C §1.4C程序的上机步骤 ★C程序开发步骤 编辑程序代码的录入 开始 生成源程序*C 编辑 源程序 编译了]法折排,面译 编译 与其它目标程序或库 有 有错? 目标程 链接」接敦配生成可执行 序 file. obi 程序*eXe 连接 可执行 执行 目标程 库函数和 file 执行 其它目标 程序 不正确 源程序目标程序可执行程序 结果正确? 内容程序设计语言机器语言机器语 正确 可执行 口 不可以 文件名后缀 ob < exe

编辑 链接 编译 执行 §1.4 C程序的上机步骤 C程序开发步骤 开 始 编 辑 编 译 连 接 执 行 有错? 结果正确? 结 束 有 源程序 file. c 目标程 序 file.obj 库函数和 其它目标 程序 可执行 目标程 序 无 正确 不正确 file.exe 程序代码的录入, 生成源程序*.c 语法分析查错,翻译 生成目标程序*.obj 与其它目标程序或库 链接装配,生成可执行 程序*.exe 源程序 目标程序 可执行程序 内容 程序设计语言 机器语言 机器语言 可执行 不可以 不可以 可以 文件名后缀 .c .obj .exe The C Programming Language Chapter 1 An Overview of C

第二章算法 algorithm ◆2.1算法的概念 ◆2.2简单算法举例 AY·2.3算法的特性 ◆2.4算法的表示 ◆2.5结构化程序设计方法

第二章 算法 algorithm  2.1 算法的概念  2.2 简单算法举例  2.3 算法的特性  2.4 算法的表示  2.5 结构化程序设计方法

2.1算法的概念 求1+2+3+.+100=2 2,再加3,再加4.最后加100,等于5050 00+(1499)+(2+98)+.+(49+51)+50=100+49*100+50=5050 对操作的描述 数据结构+算法 对数据的描述 法分类: 数值运算算法-用于求数值解(如:求方程的根… 数值运算算法一-—多用于管理领域(如:图书管理、人事管理)

2.1 算法的概念 程序=数据结构+算法 对数据的描述 对操作的描述 算法分类: ◼数值运算算法 ---- 用于求数值解(如:求方程的根…) ◼非数值运算算法 ---- 多用于管理领域(如:图书管理、人事管理…) 例:求1+2+3+…+100=? 1、1+2,再加3,再加4….,最后加100,等于5050 2、100+(1+99)+(2+98)+…+(49+51)+50=100+49*100+50=5050

刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档