Professional Documents
Culture Documents
TO PROGRAMMING
CSEB2113 PROGRAMMING I
Badariah Solemon
BS SEPT 2021
PROBLEM SOLVING, PROGRAM AND
PROGRAMMING
Section 1.1
BS SEPT 2021
1.1.1 COMPUTER PROGRAM AND PROGRAMMING
BS SEPT 2021
COMPUTER AND PROGRAM
• Computers:
Wearable
Desktop
Mainframe
• Must be GIVEN INSTRUCTIONS before they can perform actions and make
decisions.
• A set of instructions = Computer Program/Software/Code .
BS SEPT 2021
COMPUTER PROGRAMS
• Can be embedded into hardware to control its operations – embedded
system.
Satellites
Smart Vehicles
Consumer electronics
Medical Equipment Smart Cards
BS SEPT 2021
WHAT IS PROGRAMMING?
• Often called CODING or SCRIPTING
• Not only about writing computer programs
BS SEPT 2021
WHY DO CODING?
https://www.youtube.com/watch?v=Dv7gLpW91DM
BS SEPT 2021
1.1.2 PROBLEM SOLVING AND PROGRAMMING
BS SEPT 2021
PROBLEM SOLVING IN EVERYDAY LIFE
• People make decisions every day to solve problems that affect their lives.
• Problems
• Unimportant - what to watch on TV
• Important - choosing a degree program
If a bad decision is made, time and resources are wasted, so it’s important
that people know how to make decisions well.
BS SEPT 2021
COMMON STEPS TO SOLVE PROBLEMS
6
5
4 EVALUATE the
3 SOLVE the solution
2 Select the BEST problem
1 Identify
WAY to solve
problem
ALTERNATIVES
UNDERSTAND the
problem
IDENTIFY the
problem
BS SEPT 2021
PROGRAMMING & PROBLEM SOLVING
• Programming is a problem solving activity.
• When you write a program, you are actually writing INSTRUCTIONS for the computer
to SOLVE something for you.
BS SEPT 2021
PROGRAMMING LANGUAGES
Section 1.2
BS SEPT 2021
WHAT IS A PROGRAMMING LANGUAGE?
• Conceptually, programming language is a FRAMEWORK within which we
organize our ideas about data and procedures.
1. DATA 2. PROCEDURES
'objects’ / ‘things’ 'rules’ / ‘processes’
we want to define how to manipulate
manipulate data
BS SEPT 2021
1.2.1 TYPES OF PROGRAMMING LANGUAGES
Mac
h in e g u age 1101 0001 1000 0101 1000 0110
L an 0100 1100 0101 1110 0101 1010
BS SEPT 2021
WHAT IS A MACHINE LANGUAGE?
• The only language that is directly understandable by a computer’s processor.
• Certainly difficult for humans to understand.
• Consists of binary codes: 0 and 1 .
BS SEPT 2021
PROGRAMMING IN MACHINE LANGUAGE
• The language into which all programs MUST BE CONVERTED before they can
be run.
• Generally MACHINE DEPENDENT , as it varies from processor to processor
(e.g., Intel, AMD and ARM processors).
• NOT PORTABLE
• Programs may sometimes have to be completely rewritten to work on different type
of processors.
• Programming in machine language is VERY SLOW AND TEDIOUS since it is
hard to memorize all the instructions and mistakes can happen very easily.
BS SEPT 2021
WHAT IS AN ASSEMBLY LANGUAGE?
• Uses a MNEMONIC CODE to represent each machine operation.
• in words and numbers
• An intermediary language that can be UNDERSTOOD by humans.
• but is still quite difficult to use
//j = 25;
mov r3, #25
str r3, [r11, #-12]
• Processor dependent and not portable.
BS SEPT 2021
PROGRAMMING IN ASSEMBLY LANGUAGE
• Cannot be processed directly by a computer, must be converted to machine
language using ASSEMBLER.
• Easier to use than ML, BUT programmer must completely understand the
computer hardware in order to program it.
BS SEPT 2021
WHAT IS A HIGH-LEVEL LANGUAGE?
• A programming language designed to simplify computer programming
• Written in a form that is close to our human language, enabling to programmer to
just focus on the problem being solved.
• PORTABLE
• Easier to write, modify and debug as it uses English like statements
• Example:
BS SEPT 2021
PROGRAMMING IN HIGH-LEVEL LANGUAGE
• The programming structure is PROBLEM ORIENTED
• does not need to know how the computer actually executes the instructions.
• Processor independent
• the same code can be run on different processors.
• Programs written in these languages must be translated into executable
machine language using:
• Compilers
• Linkers
BS SEPT 2021
PROGRAMMING IN HIGH-LEVEL LANGUAGE
‘MAGIX BOX’
LINKER
BS SEPT 2021
1.2.2 THE C LANGUAGE
BS SEPT 2021
YOUR FIRST C PROGRAM D+R+E
• C SOURCE CODE
?
? ?
PROBLEM / IDEA PROGRAM EXECUTABLE FILE SOLUTION
High-level Language Machine Language
BS SEPT 2021
BS SEPT 2021