0% found this document useful (0 votes)
0 views47 pages

Computer Programming I Unit I Lecture Notes

Unit I of Comp 112 introduces programming concepts, including machine, assembly, and high-level languages, as well as the programmer's role. It covers the definitions and characteristics of different programming languages, including control structures like sequence, selection, and repetition. The unit emphasizes the importance of coding, syntax, and semantics in programming.

Uploaded by

ifyspot903
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views47 pages

Computer Programming I Unit I Lecture Notes

Unit I of Comp 112 introduces programming concepts, including machine, assembly, and high-level languages, as well as the programmer's role. It covers the definitions and characteristics of different programming languages, including control structures like sequence, selection, and repetition. The unit emphasizes the importance of coding, syntax, and semantics in programming.

Uploaded by

ifyspot903
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Comp 112: Computer Programming 1

Unit I
Introduction to Programming
UNIT I: INTRODUCTION TO PROGRAMMING

Content:
• Machine, Assembly and High-Level Language
• The programmer’s job
• Control Structures
What is Programming Language?

❑ Is like a special set of instructions and rules


that humans use to tell computers what to do.
❑ A programming language acts as a translator,
allowing us to write commands in a way that
is structured and logical for us, and then that
language is converted into something the
computer can execute.
Categories of Programming Language?

❑Machine Language
❑ Low-level Language
❑ High-level Language
MACHINE LANGUAGE

❑ Machine Language (1st Generation):


❑The absolute lowest level, consisting of
binary code (0s and 1s) that the
computer's CPU directly understands and
executes.
❑Extremely difficult for humans to write
and read.
MACHINE LANGUAGE

Central Processing Unit


Programmer (CPU)

Machine Language
Program
MACHINE LANGUAGE
ASCII (American Standard Code for
Information Interchange)

ASCII - is like a universal codebook for text characters


that computers use.
MACHINE LANGUAGE

Convert 'H' • 1÷2=0 remainder 1

• ASCII Value of 'H' • Reading the remainders


(uppercase): 72 (decimal) from bottom to top:
1001000
• Convert 72 to Binary:
• 72÷2=36 remainder 0 • So, 'H' in 8-bit binary
• 36÷2=18 remainder 0 (standard for ASCII) is
• 18÷2=9 remainder 0 01001000 (we add a
• 9÷2=4 remainder 1 leading zero to make it 8
• 4÷2=2 remainder 0 bits).
• 2÷2=1 remainder 0
MACHINE LANGUAGE

• Convert 'i' • 1÷2=0 remainder 1


• Reading the remainders from
• ASCII Value of 'i' bottom to top: 1101001
(lowercase): 105 (decimal)
• So, 'i' in 8-bit binary is
• Convert 105 to Binary: 01101001 (we add a leading
• 105÷2=52 remainder 1 zero to make it 8 bits).
• 52÷2=26 remainder 0
Note:
• 26÷2=13 remainder 0 • When converting a decimal number to binary,
• 13÷2=6 remainder 1 we divide by 2 repeatedly because binary is
• 6÷2=3 remainder 0 a base-2 number system.
• 3÷2=1 remainder 1 • Binary numbers only have two digits: 0 and 1.
MACHINE LANGUAGE

Putting it together:
H - 01001000
i - 01101001

Hi - 01001000 01101001
Categories of Programming Language?

❑Machine Language
❑ Low-level Language
❑ High-level Language
LOW-LEVEL LANGUAGE
LOW-LEVEL LANGUAGE

❑Assembly Language (2nd Generation):


❑A symbolic representation of machine
code, using mnemonics (short, human-
readable codes) for instructions (e.g., ADD,
MOV).
LOW-LEVEL LANGUAGE

❑Assembly Language (2nd Generation):


❑It's a slight abstraction over machine
code, but still hardware-specific.
Requires an assembler to convert it into
machine code.
❑An assembler is a special program that
acts as a translator for assembly
language.
LOW-LEVEL LANGUAGE
LOW-LEVEL LANGUAGE
LOW-LEVEL LANGUAGE
Categories of Programming Language?

❑Machine Language
❑ Low-level Language
❑ High-level Language
HIGH-LEVEL LANGUAGE

❑High-Level Languages (3rd Generation


and beyond):
❑Designed to be more human-readable
and abstract away the complexities of
computer hardware. They use elements
of natural language and mathematical
notation.
❑Examples: Python, Java, JavaScript,
C#, Ruby, Pascal, Fortran, etc.
HIGH-LEVEL LANGUAGE

❑High-Level Languages (3rd Generation and


beyond):
❑Advantages: Easier to learn, write, debug,
and maintain; highly portable across different
systems.
COMPILER

❑A compiler is a special computer program


that acts like a translator.
❑Its main job is to take a program you've
written in a human-readable language (like
C++, Java, or Python, if it's compiled) and
convert the entire thing into a language
that the computer's processor can directly
understand and execute (which is called
machine code).
HIGH-LEVEL LANGUAGE

Machine Language
Program Central
The compiler is Processing Unit
used to translate (CPU)
the high-level
language program
to a machine
language program.
MIDDLE-LEVEL LANGUAGE

❑Middle-Level Languages:
❑Languages that bridge the gap between low-
level control and high-level abstraction.
They offer more user-friendliness than
assembly but still allow for direct memory
manipulation and hardware interaction.
❑Example: C, C++ (often considered middle-
level due to pointer manipulation and direct
memory access, despite having high-level
features).
C++ AS MIDDLE-LEVEL LANGUAGE

❑Middle-Level Languages:
❑C++ is a powerful, high-level, general-
purpose programming language that
provides extensive abstraction and modern
programming paradigms. However, it also
retains the ability to perform low-level
memory manipulation and hardware
interaction, making it incredibly versatile
and efficient for a wide range of
applications.
C++ AS MIDDLE-LEVEL LANGUAGE

❑Middle-Level Languages:
❑This blend of high-level features and
low-level control is what sometimes
leads to it being described as a
"middle-level" language.
Programmer’s Job
PROGRAMMER’S JOB

❑A programmer's job is to write


instructions (code) that tell computers
exactly what to do.
❑Programmers create the software, apps,
and systems that solve problems and
perform tasks for people and businesses.
❑Essentially, a programmer is an architect
and builder of digital solutions.
PROGRAMMER’S JOB

❑A programmer's job is to translate


ideas and solutions into a language
computers understand, making them
perform specific tasks.
YOUR ROLE AS BSIT STUDENTS

❑The role of BSIT (Bachelor of Science in


Information Technology) students is to
learn how to make computers and
technology work well to help people and
businesses achieve their goals.
❑They are being trained to be the "tech
experts" who can understand, build, and
manage the digital tools and systems we
all use every day.
Programming
Terminology
PROGRAMMING TERMINOLOGY

❑Code is the set of instructions you write


using a programming language. It's like the
individual words, sentences, and
paragraphs in a recipe.
❑A Program is the complete recipe – the
entire collection of all that code, put
together in a specific order, designed to
make a computer do a specific task, like
run an app, a game, or a website.
PROGRAMMING TERMINOLOGY

❑ Coding is simply the act of writing


instructions for a computer using a
programming language.
❑ Syntax is about the form or grammar of a
programming language (the rules for how
code must be written to be valid).
PROGRAMMING TERMINOLOGY

❑ Semantics specifically refers to the


meaning of programming language
constructs and how they behave when
executed.
Control Structures
CONTROL STRUCTURES

❑Control structures in programming


are fundamental constructs that dictate the
order in which statements are executed
within a program.
❑They enable programmers to manipulate the
flow of execution, allowing programs to make
decisions, repeat actions, and respond
dynamically to different conditions and
inputs.
CONTROL STRUCTURES

❑ Sequence Structure
❑ Selection Structure
❑ Repetition Structure
SEQUENCE STRUCTURE

❑ refers to the line-by-line execution by


which statements are executed
sequentially, in the same order in which
they appear in the program.
SEQUENCE STRUCTURE
CONTROL STRUCTURES

❑ Sequence Structure
❑ Selection Structure
❑ Repetition Structure
SELECTION STRUCTURE

❑This allows the program to make decisions.


It executes different blocks of code based on
whether a certain condition is true or false.
SELECTION STRUCTURE
CONTROL STRUCTURES

❑ Sequence Structure
❑ Selection Structure
❑ Repetition Structure
REPETITION STRUCTURE

❑Also referred to as Iterative Structure.


❑This allows the program to repeat a block of
code multiple times.
REPETITION STRUCTURE
REPETITION STRUCTURE
END OF UNIT 1

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy