0% found this document useful (0 votes)
29 views

1 Chapter 1 - Intro To Computer - Programming

The document provides an introduction to computers and programming, including a brief history of computers from the abacus to modern PCs. It discusses the hardware and software components of computers, and gives an overview of different programming languages from machine language to high-level languages like C++ and Java. The key programming paradigms and their applications are also introduced.

Uploaded by

Nunalif Yawaumim
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

1 Chapter 1 - Intro To Computer - Programming

The document provides an introduction to computers and programming, including a brief history of computers from the abacus to modern PCs. It discusses the hardware and software components of computers, and gives an overview of different programming languages from machine language to high-level languages like C++ and Java. The key programming paradigms and their applications are also introduced.

Uploaded by

Nunalif Yawaumim
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Chapter 1:

Introduction to Computer
and Programming
2

Objectives :
A brief history of computer and
programming
 Introduction to programming
 Programming paradigm
 Introduction to C++
3

History of computer

 Abacus – the first device known to carry out calculations.


 Invented in Asia, used in ancient Babylon, China and
throughout Europe until the late middle ages.
 The abacus uses a system of sliding beads in a rack for addition
and subtraction.
4

History of computer

 1642, the French philosopher and mathematician, Blaise


Pascal, invented the calculating device called Pascaline.
 It had eight movable dials on wheels and could calculate
sums up to eight figures long
 Both Abacus and Pascaline could perform only the addition
and subtractions operations.
5

History of computer

 17th century, Gottfried von Leibniz invented a device that


was able to add, subtract, multiply, and divide called as
stepped reckoner.
6

History of computer (storage)

 In 1819, Joseph Jacquard, a French weaver, discovered that


the weaving instructions for his looms could be stored on cards
with holes punched in them. In essence, the cards programmed
a loom to produce patterns in cloth.
 The idea of storing information by punching holes on a card
proved to be of great importance in the later development of
computers.
7

History of computer

 In the early and mid-1800s, Charles Babbage, an English


mathematician and physical scientist, designed two calculating
machines: the difference engine and the analytical engine.
 The difference engine could perform complex operations such
as squaring numbers automatically.
8

History of computer

 19th century, Herman Hollerith invented a tabulating machine


that ran on electricity and used punched cards to store data.
 Hollerith founded the Tabulating Machine Company, which
later became the computer and technology corporation
known as IBM.
9

History of computer

 The first computer-like machine was the IBM Automatic


Sequence Controlled Calculator (ASCC) or Mark 1. It was built,
in 1944, jointly by IBM and Harvard University.
 The Mark I was 52 feet long, weighed 50 tons, and had 750,000
parts.
10

History of computer

 In 1946, the ENIAC (Electronic Numerical Integrator and


Calculator) was built at the University of Pennsylvania.
 It contained 18,000 vacuum tubes and weighed some 30 tons.
11

History of computer

 The UNIVAC I (UNIVersal Automatic Computer I) was the first


general purpose electronic digital computer design for business
application produced in the United States.
 It was designed principally by J. Presper Eckert and John
Mauchly, the inventors of the ENIAC.
12

History of computer

 The invention of transistors resulted in smaller, faster, more


reliable, and more energy-efficient computers.
 This era also saw the emergence of the software development
industry, with the introduction of FORTRAN and COBOL, two early
programming languages.
13

History of computer

 In 1977, Stephen Wozniak and Steven Jobs designed and built


the first Apple-1 computer in their garage.
14

History of computer

 In 1981, IBM introduced its personal computer (PC).


 By the mid-1990s, people from many walks of life were able to
afford the PC. Computers continue to become faster and less
expensive as technology advances.
15

Definition of Computer
 Computer – an electronic devices consist of
hardware and software and perform tasks and
produce the output
 Hardware - physical components that
constitute a computer system
 Software – programs written to perform
specific tasks
16

Hardware
17

Input Output Device


18

Software

System Software
• Operating system
• Utility program

Application Software
19

Introduction to programming
 A set of rules, words and symbols are used to
write a computer program – telling a
computer what to do.
 The source codes (program) are compiled and the
executable files (*.exe) are produced.

program1
Error free

Compiled Executable
Programmer file (*.exe)
writes program & debug
20

Type of programming languages


 High-level:closer to human language
 Low-level: Written mainly in binary or machine
code (0’s/1’s) .
21

Generation of Programming
language

 Machine language
 Assembly language
 High Level language

program  machine language

Compiler
machine language  program
Computers understand
People understand
binary(11011)
‘program’
22

Machine Language
 Binary number codes understood by a specific CPU.
 Lowest level of language
 Represent data and program instructions as 1s and 0s
 The only language that computer directly understand
 (Do not require translator)
 Not convenient to read and use.
 First generation language
 Machine - dependent
Example:
To calculate wages = rates * hours in machine
language:
100100 010001 //Load
100110 010010 //Multiply
100010 010011 //Store
23

Assembly Language
 Second generation language
 Developed to replace 1s and 0s use in machine
language.
 Use mnemonic codes : abbreviations that easy to
remember
 Requires a translator to translate the assembly program
into machine language ( assembler).
 Difficult to learn
 Machine-dependent

A for Add
C for Compare
MP for Multiply
24

Comparison
 A Machine-language Program Fragment and Its
Assembly-Language Equivalent
Memory Address Machine-Language Assembly-Language
Instructions Instructions

00000000 00000000 CLA

00000001 00010101 ADD A

00000010 00010110 ADD B

00000011 00110101 STA A


25 October 5, 2020

High-Level Programming Language

 Made easy for programmer to develop and


maintain program
 Machine- independent (can run on may
different types of computers)
 Have 3 categories : third, fourth and fifth
generation
 Written in series of English-like words
 Must be translated to machine code first
(Use translator)
26

History of Programming Languages

Computer
language
evolution

The only language understood by a computer is machine language

Machine Language Assembly Language

COBOL BASIC Fortran Smalltalk Ada

Visual Basic C and C++ Pascal Java


27

High-Level Programming Language


 Portable to many different computers.
 Easier to read, write, and maintain than machine
and assembly languages.
 Instruction are coded; programmers use this to
write programs.
 Example : COBOL (Business), FORTRAN (Scientific),
BASIC, Pascal, C, C++, C#, Java etc.
 Compiler/interpreter: translates a program (code)
written in a high-level language machine
language
28

Some Well-Known High-Level


Programming Languages
Language Application Area Origin Name
FORTRAN Scientific Programming Formula Translation

COBOL Business data Processing Common Business-Oriented


Language
Lisp Artificial Intelligent List processing

C System Programming Predecessor Language was named B

Prolog Artificial Intelligent Logic Programming

C++ Support objects and object Incremental modification of C (++ is


oriented programming the C incremental operator)

Java Supports Web Programming Originally name “Oak”


29

Some Well-Known High-Level


Programming Languages
30

Examples :
To calculate the wages = rates * hours
• Machine language
100100 010001 //Load
100110 010010 //Multiply
100010 010011 //Store

• Assembly language
LOAD rate
MULT hour
STOR wages

• High-level language – C Programming


wages = rate * hours;
31

Language Translator
Program need to translate because computer only
understand machine language
 Assembler
 Used in assembly language for translate the language
to machine language
 Interpreter
 Translates one program code statement at a time.
 Immediately displays feedback when it finds error.
 Compiler
 Translating the source code from its original language
into machine code.
 Converts the entire source program into machine
language at one time
32

Programming Paradigm

 Programming paradigms are a way to classify


programming languages based on their features.
Languages can be classified into multiple
paradigms.
 Common programming paradigm are:
 Procedural paradigm
 Object-oriented paradigm
33

Procedural paradigm

 Procedural programming is a programming paradigm,


derived from structured programming, based on the
concept of the procedure call.
 Procedures, also known as routines, subroutines, or
functions, simply contain a series of computational
steps to be carried out.
 Any given procedure might be called at any point
during a program's execution, including by other
procedures or itself.
 The first major procedural programming languages
appeared circa 1957–1964, including Fortran, ALGOL,
COBOL, PL/I and BASIC. Pascal and C
34

Object-Oriented Paradigm

 Object-oriented programming (OOP) is a programming


paradigm based on the concept of "objects", which can
contain data and method: data in the form of fields
(often known as attributes), and method, in the form of
procedures.
 Many of the most widely used programming languages
(such as C++, Java, Python, etc.) are multi-paradigm
and they support object-oriented programming and
procedural programming.
35

Introduction to C++
 Is a structured or procedural
programming and the object oriented
programming
 High level language
 Is a case sensitive language
 Developed by Bjarne Stroustrup at Bell
Labs
36

Example of a C++ Program

Source
code

Output
37

C++ program process


38

C++ program process

1. Programmer create and edit text file containing


the program (source code) with a text editor and
save it into file (source file)
2. Preprocessor to process the preprocessor
directives (begin with #).
3. Compiler to:
• Check that the program obeys the rules
• Translate into machine language (object
code)
4. Linker : to connect hardware-specific code to
machine instructions, producing an executable
code.
5. Loader : Loads executable file into main memory
6. Execution : Execute the program
39

High Level
Language to
Machine
Language
(Executable file)

Programmer

Code

Code

Executable Code
40

Integrated Development
Environments (IDEs)
 An integrated development environment, or IDE,
combine all the tools needed to write, compile, and
debug a program into a single software
application.
 Examples are Dev C++, Code Blocks, Microsoft
Visual C, Borland C Builder, CodeWarrior, etc.
41

Dev C++
42

CppDroid

You might also like