Programming Foundation - University of Commerce - 1


7/2020

Programming basics

1


Number of credits: 3 Department: Information Technology



Number of credits: 3 (30.15)

HP Code: INFO0621

Evaluate:

DC: 0.1; DTH: 0.3; DT: 06

Objective: provide basic knowledge of programming: algorithms, block diagrams; programs and programming languages; programming methods and program design techniques, basic components of programming languages. The C programming language will be used as a means of presentation.

7/2020 Programming Fundamentals 2


Chapter

Number of periods

LT

TH

Chapter 1. Overview of programming fundamentals

6

6

0

Chapter 2. Basic Components

13

9

4

Chapter 3. Arrays, Strings and Pointers

9

5

4

Chapter 4. Functions

9

5

4

Chapter 5. Structured data types

8

6

2

Total

45

30

15

Maybe you are interested!

Programming Foundation - University of Commerce - 1


7/2020 Programming Fundamentals 3


Obligatory

[1]. Dr. Nguyen Thi Thu Thuy. Basic programming textbook. Statistical Publishing House, 2014.

[2]. Pham Van At. Programming techniques C. GTVT Publishing House, 2008.

Encourage

[1]. Quach Tuan Ngoc. C programming language. Statistics Publishing House, 2003.

[2]. Ngo Trung Viet, C and C++ programming languages, GTVT Publishing House, 1995

[3]. www.cprogramming.com/tutorial.html

[4] https://randu.org/tutorials/c/.

7/2020 Programming Fundamentals 4

1.1. Algorithm

1.2. Block diagram

1.3. Programs and programming languages

1.4. Programming methods

1.5. Program design techniques


7/2020 Programming Fundamentals 5


1.1.1 Concept

1.1.2 Properties of algorithms

1.1.3 Example


7/2020 Programming Fundamentals 6

Concept 1 : An algorithm is a finite sequence of steps arranged in a specific order, each step describing exactly the operations or actions to be performed, to solve a problem.

Concept 2 : An algorithm is a finite series of operations, arranged in a specific order. After execution, from the Input we receive the desired Output.

7/2020 Programming Fundamentals 7


Input

Output

Deterministic (definite / univocal)

Correctness

Stoppage (finish/close)

Popularity

Feasibility/Effectiveness


7/2020 Programming Fundamentals 8

Requirement : Build an algorithm to solve the equation:

ax + b=0

Where a,b are real numbers entered from the keyboard

Analysis:

Input: a, b

Output: conclusion about x There are 3 possibilities:

- There is only one solution: x = -b/a when a≠0.

- The equation has no solution when a=0 and b≠0.

7/2020 - The random variable C method has infinitely many solutions when a = 0 and b = 0 . 9


Algorithm:

+ Step 1: Enter a, b.

+ Step 2: Check a≠0?

If correct go to step 3.

If incorrect go to step 5.

+ Step 3: Calculate the solution x = -b/a.

+ Step 4: Print x then go to step 8.

+ Step 5: Check b≠0?

If correct go to step 6. If incorrect go to step 7.

+ Step 6: Print “PTVN”, then go to step 8.

+ Step 7: Print “PTCVSN”.

7/2020 + Step 8: K C o n t h e r e c t i o n . tr 10

1.2.1 Concept

1.2.2 Control structures

1.2.3 Example


7/2020 Programming Fundamentals 11


Concept 1 : A block diagram is a set of symbols and rules used to represent algorithms.

Concept 2 : Block diagram is a way to represent an algorithm using geometric shapes connected by directed paths.

Ingredients :

Diamond: represents comparison operation

Rectangle: represents calculations

Parallelogram: represents data input and output operations

Oval: represents the start/end of the algorithm.

Fish 7 / c 20 2 m 0arrow : The physical body of the system performs the operations 12

a=0

Blocks


X=-b/a



Real Estate

Start block


KT

Condition check block

Calculation block




End block

Direction of implementation.



In/out a

Input/Output Block


7/2020 Programming Fundamentals 13


Sequential block diagram : Is a block diagram that represents an algorithm consisting of n blocks that, when executing the algorithm with a specific set of data, will be executed sequentially from the first block to the last block in the order in which they are written.

Branching block diagram : Is a block diagram showing an algorithm consisting of n branches, when executing the algorithm with a specific data set, only one of the n branches will be executed.

Cyclic block diagram : Is a block diagram showing an algorithm consisting of n blocks. When executing the algorithm with a specific data set, some blocks will be repeated many times depending on a certain condition that is still satisfied.


7/2020 Programming Fundamentals 14

a) Sequential structure:


CV1


CV2


7/2020 Programming Fundamentals 15



There are four basic types.

First form: Second form:

SS

D

Condition

CV1

CV2

D

Condition

CV1

CV2

CV3


7/2020 Programming Fundamentals 16

Comment


Agree Privacy Policy *