SMA 2175 Lecture 1_Introduction
SMA 2175 Lecture 1_Introduction
INTRODUCTION TO PROGRAMMING
TOPIC: INTRODUCTION
BY
JULIET MOSO
WHAT IS A COMPUTER?
Computer
Application Programs
Word-Processors, Spreadsheets,
Database Software, IDEs,
etc…
System Software
Compilers,
Interpreters,Preprocessors, etc.
Operating System, Device Drivers
Machine with all its
hardware
COMPUTER ORGANIZATION
Six logical units in every computer:
1. Input unit
Obtains information from input devices (keyboard,
mouse)
2. Output unit
Outputs information (to screen, to printer, to control
other devices)
3. Memory unit
Rapid access, low capacity, stores input information
4. Arithmetic and logic unit (ALU)
Performs arithmetic calculations and logic decisions
5. Central processing unit (CPU)
Supervises and coordinates the other sections of the
computer
6. Secondary storage unit
Cheap, long-term, high-capacity storage
Stores inactive programs
PROGRAMS
Programsare written in programming
languages (PL)
Pieces of the same program can be written in
different PLs
Languages closer to the machine can be more
efficient
As long as they agree on how to communicate
A PL is
A special purpose and limited language
A set of rules and symbols used to construct a
computer program
A language used to interact with the computer
TYPES OF COMPUTER LANGUAGES
There are three types of languages
Machine Language
Uses binary code
Machine-dependent
Not portable
Assembly Language
Uses mnemonics
Machine-dependent
Not usually portable
High-Level Language (HLL)
Uses English-like language
Machine independent
Portable (but must be compiled for different
platforms)
Examples: Pascal, C, C++, Java, Fortran, . . .
MACHINE LANGUAGE
The representation of a computer program which is
actually read and understood by the computer.
A program in machine code consists of a sequence of
machine instructions which specify what the
computer should do.
Instructions:
Machine instructions are in binary code
Instructions specify operations and memory cells
involved in the operation
Example:
Operation Address
Example:
Load Price
Add Tax
Store Cost
HIGH-LEVEL LANGUAGE
A programming language which use statements
consisting of English-like keywords such as "FOR",
"PRINT" or “IF“, ... etc.
Each statement corresponds to several machine
language instructions (one-to-many
correspondence).
Much easier to program than in assembly
language.
Data are referenced using descriptive names
Operations can be described using familiar
symbols
Example:
Cost := Price + Tax
C PROGRAMMING LANGUAGE
What is C?
C is a structured, relatively low-level, portable
programming language.
Why study C?
Many popular software tools are written in C.
Has strongly influenced many other
languages.
C-shell, java, C++, Perl, etc.
Forces the user to understand fundamental
aspects of programming.
Very concise language.
C PROGRAMMING LANGUAGE
The C Language is developed for creating system
applications that directly interact with the hardware
devices such as drivers, kernels, etc.
1. Mother language
2. System programming language
3. Procedure-oriented programming language
4. Structured programming language
5. Mid-level programming language
C AS A MOTHER LANGUAGE
C language is considered as the mother
language of all the modern programming
languages because most of the compilers, JVMs,
Kernels, etc. are written in C language,
It
makes the program easier to understand and
modify.
C AS A MID-LEVEL PROGRAMMING LANGUAGE
C is considered as a middle-level language because it
supports the feature of both low-level and high-level
languages.
Standardization
Many slight variations of C existed, and were
incompatible
Committee formed to create a "unambiguous,
machine-independent" definition
Standard created in 1989, updated in 1999
FEATURES OF C LANGUAGE
1) Simple
C provides structured approach (to break the problem into parts),
fast.
6) Memory Management
It supports dynamic memory allocation. In C language, we can
8) Pointers
We can directly interact with the memory by using the pointers.
works
Disadvantage: time consuming
portable