Introduction To C Programming
Introduction To C Programming
Chapter 1: Introduction
Outline
Introduction
What Is a Computer?
Computer Hardware
Computer Software
Computer Programming Languages
Machine Code, Assembly Languages and High-Level Languages.
The History of C
Object-Oriented Programming in C++
Compilation-Based Execution of Programs
Executing Programs Using an Interpreter
A C/C++ Interpreter Ch
Introduction
We will learn the C programming language
What is a Computer?
Computer
A computer is a machine that manipulates data based on a list of
instructions called program.
A computer consists of hardware and software.
Computer Hardware
Computer hardware is the physical part of a computer.
A typical computer consists of central processing unit (CPU), main
memory and external memory , and input and output devices.
A CPU consists of control unit (CU), arithmetic and logic unit
(ALU), and registers.
Input devices
2.
Output devices
3.
Main memory
4.
CPU:
4.1 Arithmetic and logic unit (ALU)
5. External memory
Hardware Trends
Moores Law (1965):
The number of transistors that can be inexpensively placed
on an integrated circuit increases exponentially, doubling
approximately every two years.
Based on Moores law, every two years, the following approximately
double:
CPU speed at which computers execute their programs.
The amount of main memory.
The amount of secondary memory.
Computer Software
Computer software refers to a collection of computer programs that can
be loaded into main memory and executed in the CPU of a computer.
Computer software can be classified as operating system and application
software.
An operating system is a software program for management and
coordination of activities and sharing the resources of a computer.
Application software refers to programs developed to assist users in
completing specific tasks.
A process: a running program.
Software is harder than hardware.
Stephen
Bill Joys
David Korn
Brian J. Fox
Harry H. Cheng
Tim Paterson
Ch Command Shell
Using commands pwd, cd, and ls to print the working
directory, change directory, and list files in the Ch
home directory.
C:/Ch> pwd
C:/Ch
C:/Ch> ls
bin/
demos/ docs/
include/ license/ README.TXT sbin/
config/ dl/
extern/ lib/
package/ release/
toolkit/
C:/Ch> cd docs
C:/Ch/docs>
C:/Ch/docs> ls
README.TXT
chguide.pdf
chinstall.pdf
chref.pdf
man/
2. Assembly language
Using meaningful symbols to represent machine code.
Example: add hl,de
Assembler: Assembly code machine code
Disassembler: machine code assembly code
FORTRAN
BASIC
Pascal
C
C++
Java
C#
History of C
C
C Standards
1st C standard created in 1989 by ANSI, ratified by ISO in 1990.
It is called C89. Some call it C90.
2nd C standard was ratified in 1999, called C99.
Numerical extensions such as complex numbers, variable length
arrays, and IEEE floating-point arithmetic are major enhancement
in C99. C99 will be pointed out whenever features in C99 only are
presented.
Created by Harry H. Cheng,
Structured Programming in C
A disciplined approach to writing programs in C.
Clear, easy to test and debug, and easy to modify.
Object-Oriented Programming
Objects
Software components that model items in the
real world
Modular with meaningful software units
Reusable
Moreunderstandable,betterorganized,and
easiertodevelopandmaintainthanprocedural
programming
Created by Harry H. Cheng,
C++ Language
C with classes invented by Bjarne Stroustrup at Bell Labs in 1980s.
Powerful object-oriented capabilities
polymorphism
inheritance
information hiding
C++ is very powerful, but too complicated. Without a solid foundation
in C, it is impossible to master object-oriented features of C++.
C++ is a superset of C89
C++ is no longer a superset of C99
Phases of Compilation-Based
Execution of a Program
1.
Edit
2.
Compile
3.
Link
4.
Execute
Compilation-Based Execution
of a C Program
Tcl/Tk
Python
Perl
PHP
Ruby
Ch (C/C++)
John Ousterhout
Guido van Rossum
Larry Walls
Rasmus Lerdorf
Yukihiro Matsumoto
Harry Cheng
1. Edit
2. Execute
Interpretive Execution
of a C Program
Computing Paradigm
1970s --- Mainframe
1980s --- Client/Server
1990s --- Network Computing
2000's --- Ubiquitous Computing