当前课程知识点:C Programming >  Chapter 1 Introduction >  1.3 Program, Programming Language and C Program Running Steps >  1.3 Program, Programming Language and C Program Running Steps.mp4

返回《C Programming》慕课在线视频课程列表

1.3 Program, Programming Language and C Program Running Steps.mp4在线视频

下一节:Discussion unit

返回《C Programming》慕课在线视频列表

1.3 Program, Programming Language and C Program Running Steps.mp4课程教案、知识点、字幕

大家好

我是云南大学信息学院丁海燕老师

欢迎走进C语言程序设计课堂

今天我们讲解程序

程序设计语言及C程序运行步骤

前面一再提到C语言及用C语言编写的程序

什么是程序

什么是程序设计语言

它们有什么关系

程序是一组机器操作的指令或语句序列

是算法的一种描述

先了解一下什么是指令

指令是指挥机器工作的指示和命令

整条指令以二进制编码的形式存放在存储器中

一条指令包括两部分

1操作要求 也叫操作码

指机器执行什么操作

2操作数的地址 也叫地址码 也是二进制

指出操作数在存储器或通用寄存器组中的地址

指令的执行过程

一取指令

二分析指令

计算机程序是一组能完成

一定功能的计算机指令的集合

只要让计算机执行这个程序

计算机就会自动地、有条不紊地进行工作

计算机的一切操作都是由程序控制的

离开程序 计算机将一事无成

程序设计

程序设计

就是指用计算机语言设计 编制

调试程序的方法和过程

程序的基本结构主要有三种

顺序结构 选择结构 循环结构

选择结构

也称分支结构

下面是三种程序结构图

a表示顺序结构 从程序开始

顺序执行语句1 语句2等等

最后程序结束

b选择结构 判断条件是否成立

是 则执行语句组1

否 则执行语句组2

两个分支至少执行一个

循环结构的基本形式有两种

当型循环和直到型循环

(c)当型循环

当条件为真

即表达式为非0值时

执行一遍循环体

再判断条件是否成立 成立则执行循环体

若条件不成立 则退出循环 执行后继语句

(d)直到型循环

先执行一遍循环体

再判断条件是否成立

不成立则执行循环体

当条件成立,则退出循环

执行后继语句

在C语言中

每个函数都用来实现一个或几个特定功能

被调用的函数可以是库函数

也可以是自己编制设计的函数

C程序对计算机的操作由C语句完成

什么是计算机语言?

计算机语言是指

人和计算机交流信息的

计算机和人都能识别的语言

下面来看计算机语言发展的历程

计算机语言的发展历经三代

第一代机器语言是由0和1组成的指令

例如

这些0,1代码是机器语言编写的9+8程序

第二代汇编语言是用英文字母和数字表示的指令

例如mov AL,9

ADD AL,8

是用汇编语言编写的9+8程序

第三代高级语言是接近于人的自然语言和数学语言

高级语言分为面向过程的语言和面向对象的语言

PRINT 9+8 是用BASIC语言编写的9+8程序

用C语言编写的9+8程序如下

{ printf("%d ", 9+8); return 0;}

显然 写高级语言比写机器语言程序容易

那么怎样让计算机读懂高级语言呢

首先 程序员按照该语言的语法编写程序源代码

即把自己的意图写入源代码中

其次,用编译器读入源代码

即把程序员的意图转换成可执行程序

供他人使用

程序在计算机内部是如何运行的呢

首先通过输入设备输入源程序和数据

存储在存储器中

控制器从存储器取出一条程序指令

分析并执行指令

如果需要计算

控制器向存储器发出存取命令

将相应数据送入运算器进行各种运算

再将计算结果送回存储器

最后将程序运行结果输出到输出设备上

下面我们来学习运行C语言程序的步骤和方法

上机输入和编辑源程序 保存为.c文件

可使用codeblocks.exe、vs 2010

VC++6.0等集成开发环境

2.对源程序进行编译生成.obj文件

3. 连接处理生成.exe文件

4.运行可执行程序得到运行结果

这是运行C程序的步骤的图示

编辑程序保存为.c的源程序

编译 编译正确生成.obj的目标文件

然后连接

连接正确则生成.exe的用户可执行文件

运行.exe文件得到程序运行结果

若运行结果正确程序结束

不正确则需要重新编辑源程序

再重复编译、连接和运行三个步骤

下面介绍codeblocks中C源程序的运行步骤

1启动并进入codeblocks

2选择“文件”→“新建” →“空白文件”

打开空白文件

输入源程序

3选择“文件” →“save file"

保存文件

在“文件名”文本框输入C源程序文件名

如“1-1.c”

并选择文件的存储路径

4选择“构建” →“编译当前文件”

编译程序

查看窗口底部的信息窗有无错误提示

有则改正错误后再编译

无错误则点击“构建” →“构建并运行”

即出现程序运行窗口

输入数据

得到运行结果

5若修改过源程序

需重新保存、编译、运行

案例1.2

求两个整数中较大者

1启动codeblocks

2选择“文件”→“新建” →“空白文件”

打开空白文件

输入源程序

声明被调用函数max

定义3个变量a、b、c

通过键盘为变量a、b输入值

调用函数max

将其返回值赋给c

输出c的值

定义max

定义变量z

通过if语句判断出x、y中较大者

并将其赋给z

将z作为函数max的返回值带回主调函数

3选择“文件” →“save file”保存文件

在“文件名”文本框输入C源程序文件名

如“1-2.c”

并选择文件的存储路径

4选择“构建” →“编译当前文件”

编译程序

查看窗口底部的信息窗有无错误提示

有则改正错误后重新编译

无错误则点击“构建” →“构建并运行”

出现程序运行窗口

输入3,7

输出max=7

若修改过源程序

需重新保存 编译 运行

好了 同学们

程序、程序设计语言及C程序运行步骤

我们就学习到这儿

下节课再见

C Programming课程列表:

Chapter 1 Introduction

-1.1 The development and characteristics of C language

--1.The development and characteristics of C language .mp4

--1.1 Self test questions

-1.2 A simple C Language program

--1.2 A simple C Language program.mp4

--Discussion unit

--【Source program】 Example 1.1 output a line of text Hello, world! "

--【Source program】 Example 1.2 program composed of multiple functions, find the larger of two integers

--1.2 Self test questions

-1.3 Program, Programming Language and C Program Running Steps

--1.3 Program, Programming Language and C Program Running Steps.mp4

--Discussion unit

--Running steps of C source program in CodeBlocks

--1.3 Self test questions

-Course references

-chapter 1 Self-Test

Chapter 2 Algorithm

-2.1 The Concept and Description of Algorithms

--2.1 The Concept and Description of Algorithms.mp4

--Discussion unit

--2.1 Self test questions

-2.2 Examples of Simple Algorithms, Computational Thinking and Structured Programming

--2.2 Examples of Simple Algorithms, Computational Thinking and Structured Programming.mp4

--Discussion unit

--2.2 Self test questions

-Chapter 2 Self test questions

Chapter 3 Programming in C

-3.1 Simple Structure and Identifier of C Language Program

--3.1 Simple Structure and Identifier of C Language Program.mp4

--【Source program】 Example 3.1 input two integers and output the sum of two numbers.

--【Source program】 Example 3.2 input two integers and output the average value.

--【Source program】 Example 3.3 output the value of the character variable.

--3.1 Self test questions

-3.2 Constants, Variables and Assignments

--3.2 Constants, Variables and Assignments.mp4

--Discussion unit

--3.2 Self test questions

-3.3 Arithmetic, assignment, increment and decrement operators

--3.3 Arithmetic, assignment, increment and decrement operators.mp4

--3.3 Self test questions

-3.4 Conditions, commas, addresses, byte operators, and mixed operations among various numerical data

--3.4 Conditions, commas, addresses, byte operators, and mixed operations among various numerical data

--【Source program】 example of sizeof

--3.4 Self test questions

-3.5 Input and Output Examples and Character Input and Output

--3.5 Input and Output Examples and Character Input and Output.mp4

--【Source program】 Example. Find the root of quadratic equation of one variable.

--【Source program】 Example 1. Successively output three characters of BOY.

--【Source program】Example 2. Input 3 characters of BOY from the keyboard and output them to the screen

--3.5 Self test questions

-3.6 Formatted output printf function

--3.6 Formatted output printf function.mp4

--【Source program】 Example 3.4 output of integer data.

--【Source program】 Example 3.5 real data output.

--【Source program】 Example 3.6 character data output.

--【Source program】 Example 3.7 uses %s to output a string.

--3.6 Self test questions

-3.7 Formatted input scanf function

--3.7 Formatted input scanf function.mp4

--Discussion unit

--【Source program】 Example 3.8 Input and output integer data

--【Source program】Example 3.9 Input and output single precision and double precision real data.

--【Source program】Example 3.10 input and output character data.

--【Source program】Example 3.11 input and output string.

--3.7 Self test questions

-3.8 Basic Data Types of C Language

--3.8 Basic Data Types of C Language.mp4

--3.8 Self test questions

-Chapter 3 Self test questions

-Operator and expression self test questions

Chapter 4 Selection Structure

-4.1 Relational operators, logical operators, and if statements

--4.1 Relational operators, logical operators, and if statements.mp4

--Discussion unit

--【source example】Example 4.1 Find the root of the quadratic equation of one variable.

--【Source program】Example 4.2 Input two real numbers and output them from small to large.

--4.1 Self test questions

-4.2 Switch Statement

--4.2 Switch Statement .mp4

--Discussion unit

--【Source program】Example 4.3 uses switch statement to implement simple menu program

--【Source program】Example 4.4 converts centesimal score into the corresponding grade system score.

--4.2 Self test questions

-4.3 Examples of Selection Structural Programs

--4.3 Examples of Selection Structural Programs.mp4

--【Source program】 Example 4.5 determines whether a year is a leap year.

--【Source program】 Example 4.6 find the solution of quadratic equation of one variable.

--【Source program】Example 4.7 calculate the transportation cost for the user.

--4.3 Self test questions

-Chapter 4 Self test questions

Chapter 5 Loop Structure

-5.1 While and Do-While Statement

--5.1 While and Do…while statement.mp4

--Discussion unit

--【Source program】example 5.1 Use while statement to find 1 + 2 + 3 + +100

--【Source program】example 5.2 using do while statement to find 1 + 2 + 3 + +100

--5.1 Self test questions

-5.2 For Statement

--5.2 for statement.mp4

--【Source program】example 5.3 Use for loop to find 1 + 2 + 3 +100

--5.2 Self test questions

-5.3 Change the State of Loop Execution and Nested Loop

--5.3 Change the state of loop execution and nested loop .mp4

--【Source program】example 5.4 collecting charity donations

--【Source program】example 5.5 output a number between 100 and 200 that cannot be divided by 3.

--【Source program】multiplication table

--【Source program】example 5.6 Output the following 4*5 matrix.

--5.3 Self test questions

-5.4 Loop Structure Program example 1

--5.4 Loop structure program example 1.mp4

--【Source program】example 1

--【Source program】example 2

--【Source program】example 3

--【Source program】 Example 4

--5.4 Self test questions

-5.5 Loop Structure Program example 2

--5.5 Loop structure program example 2.mp4

--【Source program】example 5. Output the following figure.

--【Source program】example6. The problem of 100 chickens and 100 coins

--【Source program】example 7. Find the approximate value of PI

--5.5 Self test questions

-Chapter 5 Self test questions

Chapter 6 Batch Data Processing with Array

-6.1 Definition, Reference and Initialization of One-Dimensional Arrays

--6.1 Definition, Reference of One-Dimensional Arrays.mp4

--Discussion unit

--6.1 Self test questions

-6.2 One-Dimensional Array Programming

--6.2 One-Dimensional Array Programming.mp4

--【Source program】example 1. Fibonacci sequence

--【Source program】example 2. Find the maximum value and the minimum value.

--【Source program】example 3 exchanging array elements in reverse order.

--【Source program】example 4. Bubble sorting.

--6.2 Self test questions

-6.3 Definition, Reference and Initialization of Two-Dimensional Arrays

--6.3 Definition, Reference of Two-Dimensional Arrays.mp4

--6.3 Self test questions

-6.4 Two-Dimensional Array Programming

--6.4 Two-Dimensional Array Programming.mp4

--【Source program】example 1. Get the average score of each subject.

--【Source program】Example 2. The elements of row and column of a 2D array are interchanged

--6.4 Self test questions

-6.5 Definition, initialization and input and output of character arrays

--6.5 Definition, initialization and input and output of character arrays .mp4

--Discussion unit

--【Source program】Example 6.6 Output a known string.

--【Source program】Example 6.7 Output a diamond.

--【Source program】Example 6.10 Sorting of strings.

--6.5 Self test questions

-6.6 String Processing Function

--6.6 String Processing Function.mp4

--6.6 Self test questions

-6.7 Character Array Programming

--6.7 Character Array Programming.mp4

--6.7 Self test questions

-Chapter 6 Self test questions

Chapter 7 Modular Programming with Functions

-7.1 Function Concept and How to Define and Call Functions

--7.1 Function Concept and How to Define and Call Functions.mp4

--【Source program】Example 7.1

--7.1 Self test questions

-7.2 Data Transfer in Function Call, Call Procedure and Function Return Value

--7.2 Data Transfer in Function Call, Call Procedure and Function Return Value.mp4

--Discussion unit

--【Source program】Example 7.2

--7.2 Self test questions

-7.3 Declarations of called functions and nested calls to functions

--7.3 Declarations of called functions and nested calls to functions .mp4

--【Source program】Example 7.4 use a function to find the sum of t

--7.3 Self test questions

-7.4 Recursive call to function

--7.4 Recursive call to function.mp4

--【Source program】Example 7.6. How old is the fifth student?

--【Source program】Example 7.7 Use recursion method to find n!

--7.4 Self test questions

-7.5 Array as function parameter (1)

--7.5 Array as function parameter (1).mp4

--Discussion unit

--【Source program】Example 7.10

--7.5 Self test questions

-7.6 Array as function parameter (2)

--7.6 Array as function parameter (2).mp4

--【Source program】Selection sorting.

--【Source program】Example 7.13 find the maximum of a 3×4 matrix.

--7.6 Self test questions

-7.7 Local and global variables, internal and external functions

--7.7 Local and global variables, internal and external functions.mp4

--【Source program】Example 7.14

--7.7 Self test questions

-7.8 The Survival Period of Variables and the Storage Mode of Local Variables

--7.8 The Survival Period of Variables and the Storage Mode of Local Variables.mp4

--【Source program】Example 7.17

--7.8 Self test questions

-7.9 Storage Categories of Global Variables

--7.9 Storage Categories of Global Variables.mp4

--7.9 Self test questions

-Chapter 7 Self test questions

Chapter 8 Pointer

-8.1 Pointer Concept, Definition and Reference of Pointer Variables

--8.1 Pointer Concept, Definition and Reference of Pointer Variables.mp4

--【Source program】Example 8.1

--8.1 Self test questions

--Discussion unit

-8.2 Pointer variables as function parameters

--8.2 Pointer variables as function parameters.mp4

--Discussion unit

--【Source program】Example 8.3. Exchange two data with function call.

--8.2 Self test questions

-8.3 Pointer of array element, operation of pointer and reference of array element by pointer

--8.3 Pointer of array element, operation of pointer and reference of array element by pointer.mp4

--【Source program】Point to array elements with pointer variables.

--8.3 Self test questions

-8.4 Using Array Name as Function Parameter

--8.4 Using Array Name as Function Parameter.mp4

--【Source program】Store array elements in reverse order.

--8.4 Self test questions

-8.5 Reference to multidimensional arrays by pointers

--8.5 Reference to multidimensional arrays by pointers.mp4

--【Source program】Pointer variable pointing to one-dimensional array.

--8.5 Self test questions

-8.6 Referencing strings through pointers

--8.6 Referencing strings through pointers.mp4

--【Source program】Reference string by pointer.

--8.6 Self test questions

-8.7 Character pointer as function parameter

--8.7 Character pointer as function parameter.mp4

--【Source program】Character pointer as function parameter.

--8.7 Self test questions

-8.8 Pointer pointing to function

--8.8 Pointer pointing to function.mp4

--【Source program】Pointer variable pointing to the function.

--8.8 Self test questions

-8.9 Functions that return pointer values

--8.9 Functions that return pointer values.mp4

--【Source program】Intercept substring.

--8.9 Self test questions

-8.10 Pointer arrays and multiple pointers

--8.10 Pointer arrays and multiple pointers.mp4

--【Source program】Sorting of strings.

--8.10 Self test questions

-8.11 Dynamic memory allocation and pointer variables pointing to it

--8.11 Dynamic memory allocation and pointer variables pointing to it.mp4

--Discussion unit

--【Source program】Dynamic memory allocation.

--8.11 Self test questions

-Chapter 8 Self test questions

Chapter 9 Structure

-9.1 Define and use structural variables

--9.1 Define and use structural variables.mp4

--【Source program】Structure variable

--9.1 Self test questions

-9.2 Using structure arrays

--9.2 Using structure arrays.mp4

--Discussion unit

--【Source program】Structure array

--9.2 Self test questions

-9.3 Structure pointer

--9.3 Structure pointer.mp4

--【Source program】Structure pointer

--9.3 Self test questions

-Chapter 9 Self test questions

CodeBlocks Baidu online disk download

-CodeBlocks Baidu online disk download address

Final Exam

-Final Exam

--final exam

1.3 Program, Programming Language and C Program Running Steps.mp4笔记与讨论

也许你还感兴趣的课程:

© 柠檬大学-慕课导航 课程版权归原始院校所有,
本网站仅通过互联网进行慕课课程索引,不提供在线课程学习和视频,请同学们点击报名到课程提供网站进行学习。