C/C++ Programming Techniques: ET2031 / ET2031E
C/C++ Programming Techniques: ET2031 / ET2031E
C/C++ Programming Techniques: ET2031 / ET2031E
ET2031 / ET2031E
1
Course overview
Overview
• Course:
• Course: C/C++ Programming techniques
• Course code: ET2031 2(2-0-1-4)
• Teams code: ......
• Instructor
• PhD. Đỗ Thị Ngọc Diệp
• Communication Engineering Faculty – SEEE – HUST
• Speech Communication Department – MICA Institute
• Email: diep.dothingoc@hust.edu.vn
3
Course syllabus
Week Lecture
1-2 Introduction, basic concepts
3 Excercise
4 Arrays and Pointers
5-6 Function Oriented Programming
7 Excercise
8 Data structure
9-10 Object-Oriented Programming
11 Excercise
12 Inheritance
13 Standard Template Library
14 Other techniques
15-16 Project presentation
Requirements for students
5
Textbooks and References
• Textbooks
• [1] Nguyễn Thanh Bình, Nguyễn Hoài Giang. Ngôn ngữ lập trình C và Cấu
trúc dữ liệu. NXB Giáo Dục 2017.
• [2] Nguyễn Việt Hương. Ngôn ngữ lập trình C++ và cấu trúc dữ liệu. NXB
Giáo dục, 2000.
• References
• [1] Lê Đăng Hưng, Tạ Tuấn Anh, Nguyễn Hữu Đức, Nguyễn Thanh Thủy.
Lập trình hướng đối tượng với C++. NXB Khoa học kỹ thuật, 2006.
• [2] Trần Văn Tư, Nguyễn Ngọc Tuấn. 450 bài tập về lập trình C++. NXB
Thống kê, 2000.
• [3] C++ & Lập trình hướng đối tượng, GS. Phạm Văn Ất, NXB KH&KT
• [4] The C Programming Language – 2nd Edition, Brian W. Kerninghan &
Dennis M. Ritchie, Prentice-Hall,1988
• [5] The C++ Programming Language – 4th Edition, Bjarne Stroustrup,
Addison-Wesley, 2013
• Other programming languages
6
Reference
• Online tutorials
• Interactive learning
• Advanced topics
https://www.learn-c.org/
7
Course Evaluation
8
Introduction
9
Content
10
I. Computer software development progress
11
Computer development history
12
Computer development history
13
Computer architecture
• Hardware
https://www.techsignin.com
14
Computer architecture
https://www.youtube.com/watch?v=5AjReRMoG3Y
15
Computer architecture
• Operating System:
• is a system software
• Allows users to manipulate:
• computer hardware
• external device
• run application software (Executive programs)
https://www.youtube.com/watch?v=5AjReRMoG3Y
https://sensorstechforum.com 16
Executive programs – Machine code
• CPU:
• Read/Write to memory Memory
• Perform math operations, etc. CPU
17
How do computers read code - Compiler
18
Compile source code into binary
…
in binary
19
… and run the binary
in binary
in hexadecimal assembly code
do the correct
action in the memory
Memory location
20
Program error
21
Software development process
• Software lifecycle:
• Analysis of the requirements of the problem
(analysis + define requirements)
• Software design (design)
• Building the product (develop)
• Coding/ Programming (source code)
• Testing, Debugging
• Documentation
• Deployment in reality (machine code)
• Maintenance, update and further development
• Out-of-date
https://www.javatpoint.com
22
II. Software Programming
23
General concepts
24
General concepts
25
Programming technique
26
Programming languages
• Development process:
• Machine language: direct use of binary code, no need to compile, depends on
the processor.
• 2nd generation (assembly language): need to compile, readable, depends on
the processor.
• 3rd generation (high level language): control structures, data types,
encapsulation. (Fortran, C, C++, Java and JavaScript,…)
• 4th generation: improve efficiency such as reducing
error-prone elements, syntax closer to spoken
language. (SQL, Perl, Python,…)
• 5th generation: use visual tools to
develop a program. (Mercury, Prolog)
http://btechsmartclass.com
27
Programming languages
28
Imperative programming
• Typical: assembly
• The program consists of a set of instructions that are executed sequentially
(from top to bottom)
• Does not show structure, poorly supports modularization
• Difficult to solve complex problems
Assembly language
Structural programming
32
Event-driven programming
34
History of the C language
• Born in the 1970s, associated with the development of the Unix OS.
• Author: Dennis Ritchie (Bell Laboratories)
• Target:
• Enhancing efficiency
• Capable of accessing low-level hardware, capable of direct memory access
• Structured languages (instead of programming in assembly language)
• Short syntax, few keywords
• No hardware dependency
• Structures, functions, encapsulation, etc.
35
History of the C++ language
36
C-based languages
• C++ includes all features of C, but adds classes and other features to support
object-oriented programming
• Java: is based on C++ and therefore inherits many C features
• C#: is a more recent language derived from C++ and Java
• Perl: is originally a fairy simple scripting language and overtime it has grown
and adopted many of the features of C
37
C Compiler and linker
http://btechsmartclass.com
https://teaching.csse.uwa.edu.au/units/CITS2002/lectures/lecture02/03.html
38
Why choose C/C++
• Advantage:
• efficient, flexible, stable
• widely supported on different environments
• many libraries and tools available
• wide range of applications: on server, embedded system, OS, etc.
• original language, making learning other programming languages easy
• Defect:
• Language [too] complicated
• Error control is more difficult than in high-level languages (Java, .NET, scripts,
etc.), especially due to the use of pointers
Write code
Write code
Compile
Compile
Run
Run
40
Tools
• LINUX/Ubuntu
• IDE
• Interface
41
Tools
• Windows
• Editors: Notepad++/Visual Studio Code + C/C++ extension
• Compilers: Cygwin/MinGW
• IDE: Codeblocks/Visual Studio Community/Netbeans/Eclipse/Dev-C
42
Tools
43
• https://www.youtube.com/watch?v=YOLN-t09-tM
• https://www.youtube.com/watch?v=rydtxg8gQz0
44