CS计算机代考程序代写 javascript computer architecture python algorithm compiler c# Java Lecture 01 Introduction to Programming in C

Lecture 01 Introduction to Programming in C

2
Eric Chen 2019-03-05
Objectives –Introduction
• Motivation to learn C
• Understand what a computer is and what a program is
• the von Neumann model and programming
• C program development process
• CodeBlocks programming enviornment

Programming in C
• How many computer languages do you know?
– Java, JavaScript, C#, PHP ?
– http://en.wikipedia.org/wiki/List_of_program
ming_languages
• How many computer languages can you?
– Java ?
• Why do we learn C? Your motivation?
– ??
3
Eric Chen 2019-03-05

TIOBE Programming Community Index (March 2019)
4
Eric Chen 2019-03-05

TIOBE Programming Community Index
• Index in March 2019
5
Eric Chen 2019-03-05

Programming Language Use in Embedded Designs
6
Eric Chen 2019-03-05

7
Eric Chen 2019-03-05
C is one of the most popular languages

What is C?
• Dennis Ritchie – AT&T Bell
Laboratories in 1972
– 16-bit DEC PDP-11 computer
(http://en.wikipedia.org/wiki/PDP-11) • Widely used today
– extends to newer system architectures (portable)
– efficiency/performance – Low-level access
8
Eric Chen 2019-03-05

Versions of C
Evolved over the years:
• 1972 – C invented
• 1978 – The C Programming Language published; first specification of language
• 1989 – C89 standard (known as ANSI C or Standard C)
• 1990 – ANSI C adopted by ISO, known as C90
• 1999 – C99 standard
– mostly backward-compatible
– not completely implemented in many compilers
• 2007 – work on new C standard C1X announced
– C11 is the newest version
• Not all C compilers support newest versions.
9
– In this course: ANSI/ISO C (C89/C90) Eric Chen 2019-03-05

What is C used for?
• C is widely used for systems
programming:
– Develop operating systems, like Linux
• C is a key language in developing embedded applications where resources (memory/CPU) are limited
10
Eric Chen 2019-03-05

11
• Low high-level language, faster code Eric Chen 2019-03-05
C and related languages
• More recent derivatives: C++, Objective C, C#
• Influenced: Java, Perl, Python
• C lacks:
– Exception handling
– range-checking (be careful with array index)
– garbage collection (memory leak bug)
– object-oriented programming

Watch video clip
• Write in C

12
Eric Chen 2019-03-05

Computing model
• A computer is a programmable machine that receives input, stores and manipulates data/information, and provides output in a useful format.
input
13
Eric Chen 2019-03-05
Computer
Data processing
output

Programmable Computer Model

Computers – general-purpose machines

Program vs Algorithm
program
– is a set of instructions
that tells the computer what to do with data.
– written in a computer language. • An algorithm
– A step by step instruction to solve a problem
• Programming
– develop an algorithm
– implement the algorithm
•A

Computer architecture
• Every computer today is based on the von
Neumann Model
– input/output devices
– CPU (central processing unit) • ALU (arithmetic logic unit)
• Control unit
– memory ( store program + data )
16
Eric Chen 2019-03-05

A programmer should …
• Get data into computer • Process data
• Present results
• Data inside the computer ? – Memory: address, content – Representation
18
Eric Chen 2019-03-05

A programmer should …
• Develop an algorithm to solve a problem • Implement it in C ( or other language)
• Test and evaluate the result
19
Eric Chen 2019-03-05

Watch Video
• Intro to Computer Architecture (4 min)
https://www.youtube.com/watch?v=HEjPop- aK_w
20
Eric Chen 2019-03-05

21
Writing/running C programs
• C is high level language. C program should be compiled into machine codes before it can be executed.
– compilation: from *.c to *.o
– linking: from *.o to *.exe
• A program development environment is required to develop and test the program.
• In this course, we recommend
– CodeBlocks
• it is an integrated development environment (IDE)
– it is ok, if you choose to use other environments Eric Chen 2019-03-05

Watch Video clips
• C Programming Tutorial
https://www.youtube.com/playlist?list=PL 6gx4Cwl9DGAKIXv8Yr6nhGJ9Vlcjyymq
– 1 introduction (5min)
– 2 seting up CodeBlock (7min)
– 3 How Computer Programs Work (5min)
Eric Chen 2019-03-05

23
Set Up C Programming Environment
• You should set up one environment for C programming
• CodeBlocks is recommended
• Follow the tutorial (#2 in the referenced youtube tutorial) to set up the CodeBlocks
• Test the environment by editing, compiling and executing the first example program
– ex1.c is available on course page Eric Chen 2019-03-05