Vous êtes sur la page 1sur 30

Introduction to

Computer Programming
 List different programming languages, its
description and its category.
The first part of our program
is a Song Solo to be led by
Onyok.
Programming Concepts
based on every day activities
A few examples
• Recipe to make favorite food
• Assembly instructions for a toy
• Getting ready in the morning to go to school
What is common about these activities?
Sequence
Programming concepts:
Sequence structure
instruction 1;
instruction 2;
instruction 3;

A few more examples
• Go to movie or study?
• Eat salad or sandwich?
• Go to job or go for higher studies?
What is the common thing here?
Selection or IF statement
Selection structure
IF condition is true THEN
do this;
ELSE
do that;
ENDIF
A few more examples
• Eat chips from a packet
• Take an exam that has several questions
What is the common thing here?
Repetition / Loops
Repetition structure
WHILE (more items to process)
process the next item;
ENDWHILE

FOR month = 1 to 12
do monthly processing
ENDFOR
Programming Concepts
• Structures: Sequence, Selection & Repetition
• Foundation for Programming
• Every complex program is only a combination
of these structures.
More things we do…
• Use a box to move lots of things from one
room to another
• Carry a pack of candies to class on your
birthday!

• What is the common thing here?


Collection / Arrays
Arrays
• enable us to store data of similar type
together.
• enables us to handle varying size data.
• Lines of code do not increase with more data!

FOR each item in array


add item to total
ENDFOR
Even more things we do…
• Get phone call when you are driving a car
• Friend knocks on the door when you are
watching a movie
What is the common thing here?
Interrupts / events
Programming
• the act or process of writing a program so that
data may be processed by a computer.

Programming Languages
• is a set of commands, instructions, and other
syntax use to create a software program.
–Machine Language - Assembly Language
•Uses binary code Uses mnemonics
•Machine-dependent Machine-dependent
•Not portable Not usually portable
A Layered View of the 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
Syntax & Semantics
• Syntax:
– The structure of strings in some language. A language's
syntax is described by a grammar.
– Examples:
• Binary number
<binary_number> = <bit> | <bit> <binary_number>
<bit> =0|1
• Identifier
<identifier> = <letter> {<letter> | <digit> }
<letter> =a|b|...|z
<digit =0|1|...|9
• Semantics:
– The meaning of the language
Compilation into Assembly L

Source Assembly
Program Compiler Language

Assembly Machine
Assembler
Language Language
Running Programs
• Steps that the computer goes through to run a
program:
Memory

Machine language
program
(executable file)
Input Data Data entered CPU
during execution

Computed results
Program Output
Program Execution
• Steps taken by the CPU to run a program
(instructions are in machine language):
1. Fetch an instruction
2. Decode (interpret) the instruction
3. Retrieve data, if needed
4. Execute (perform) actual processing
5. Store the results, if needed
Program Errors
• Syntax Errors:
– Errors in grammar of the language
• Runtime error:
– When there are no syntax errors, but the program can’t
complete execution
• Divide by zero
• Invalid input data
• Logical errors:
– The program completes execution, but delivers incorrect
results
– Incorrect usage of parentheses
Interpretation

Source
Program

Interpreter Output

Input

• The interpreter stays around during execution


• It reads and executes statements one at a time
References:
• www.utdallas.edu/~jeyv/lectures/enjoyable_progra
mming_usa.pptx
• www.cs.cmu.edu/~violetta/CMP131/Lectures/Week1
.3.ppt
• https://www.slideshare.net/VarunGarg7/lect-1-
introduction-to-programming-languages
• https://www.collinsdictionary.com/dictionary/englis
h/programming
• https://techterms.com/definition/programming_lang
uage
Seatwork: ¼ sheet of paper

• Given the
picture of a
maze, give the
fastest path so
that the blue
object can exit.
Draw arrows (as
directions for
your answer).

Vous aimerez peut-être aussi