Introduction to Programming
What is Programming?
• Computer – A machine that processes data according to
instructions
– E.g. PC, smartphone, mainframe, game console, …
– Data: user inputs, text, keystrokes, audio, video, etc.
– Instructions: programs, apps, etc.
• Computer Program – A set of instructions that tells a
computer how to process data
• Programming – Writing sets of instructions in some
languages that tell computers what to do
2
Programming Languages
11000100101010010100101111101010
Machine
The action is
Language Inconveniently, machines only speak their called
mother tongue, usually in binary codes. “Assemble”.
add eax, ebx
Assembly
Language Assembly language is a nicer one. Yet, it is The action is
all not human friendly. called
“Compile”.
total = principal + profit * 0.9;
High-level
Programming
As a human programmer, we usually write
Language
in high-level programming languages.
3
Programming Cycle Language translation
and grammar
checking with some
software (compilers)
Save as a
program code
source file, e.g. Compilation
(Build)
“hello.c” Compile +
Assemble
Compilation FAILED!
Use a text editor to write Read error and
high-level program code warning messages,
modify code to retry.
NO! Check results and
YES, modify code, i.e., debugging
Bingo! Is the
result Generate object code
and save the target in a
correct?
machine executable file,
e.g. “MyApp.exe”
Program testing Execution
4
Online Tools
There exist online C compilers such as replit.com,
onlinegdb.com, programiz.com etc
• Online platform, great for learners!
• You can practice programming as long as you have
a browser (preferably on Chrome, PC/Mac)
• No excuses not to practice programming!
9
Fundamentals of Programming
• Understand the basic concepts and principles of
programming
• Understand and memorize the syntax of a programming
language
• Turn your idea/solution into equivalent instructions
• Know what APIs (Application Programming Interface) are
available and learn how to use them
6
Why Learn Programming?
• This course is compulsory for all engineering
students. Why?
• Why do I need to learn programming?
• Is this course only important to those who want to
study Computer Science?
– The answer is NO
7
Why Learn Programming?
• Maybe you are interested in...
– Internet-of-Things, Embedded Systems
– Enterprise Systems, e-Commerce
– Fin-Tech, Blockchain, Mobile Payment Systems
– Biomedical and Environmental Innovations
– Network Security, Big Data, Cloud Computing
– Robotics, Artificial Intelligence, Game Industry
• In all these wonderful and exciting engineering
frontiers, software is a crucial component
• Programming is crucial to the creation of software
8
Why Learn Programming?
• Learning programming well will benefit your
future study in your future courses in ANY
department major programs
• So please work hard in this course!
9
Our Tools – Online Judge System
• An online platform for code submission
• You can submit your completed lab exercises as
long as you have a browser (preferably on Chrome,
PC/Mac)
• We will introduce the tool in detail later
10
Our Tools – Code::Blocks
• An Integrated Development Environment (IDE)
• Project and file management
• Code editing
• Build (Compile + Link) and Run
• Debugging support
• Open source and free!
• We will also introduce the tool in detail later
Other Programming Tools
• Visual Studio Community (Advanced)
– An Integrated Development Environment (IDE)
• Editor + Compiler + Debugger + Other development tools
– VS Community Edition is free to download
• Sign in using CUHK CWEM Microsoft O365 account
– More tools from Microsoft
(Free!)
• https://visualstudio.microsoft.com/free-developer-offers/
• Sign up with CUHK CWEM email address, or consult ITSC website
– Not needed to do your lab exercises
12
Reading Assignment
• C: How to Program, 8th ed, Deitel and Deitel
• Chapter 1 Introduction to Computers
– Sections 1.1 – 1.5, 1.9
13