Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to Programming CST 200 - JavaScript. Objectives Define software Identify the different types of software Differentiate the different types of programming.

Similar presentations


Presentation on theme: "Intro to Programming CST 200 - JavaScript. Objectives Define software Identify the different types of software Differentiate the different types of programming."— Presentation transcript:

1 Intro to Programming CST 200 - JavaScript

2 Objectives Define software Identify the different types of software Differentiate the different types of programming languages – machine language, assembly language, high-level languages Differentiate between procedure-oriented programs and object-oriented programs Understand the three basic control structures: sequence, selection and repetition Define an algorithm 2Intro to Programming

3 Software vs. Hardware Every computer system combines software and hardware Software is the collection of computer programs and related data that tells a computer what to do – Series of instructions Hardware consists of the physical, electronic, mechanical components – Keyboard, mouse, monitor, memory, hard drive 3Intro to Programming

4 Types of Software Two categories of software exist: Application software describes computer programs that allow users to perform specific tasks – word processors, web browsers, email client System software describes computer programs that operate and control the hardware connected to the computer – Operating systems, device drivers 4Intro to Programming

5 Programming Computer programming is the art and science of specifying the set of instructions (programs) that tell the computer what to do Computer programs are written in programming languages Just as written languages define symbols and rules that enables humans to communicate, programming languages define symbols and rules that enable humans to communicate with computers 5Intro to Programming

6 Types of Programming Languages Programming languages fall into different categories, based upon who (or what) is able to understand and execute it Three categories are: – Machine language – Assembly language – High-level language 6Intro to Programming

7 Machine Language Machine language (machine code) is the series of instructions that a computer (machine) directly understands – Binary language, consisting entirely of 0 and 1’s – Extremely difficult to program – Hardware-dependent: each family of CPU’s (Intel x86, AMD Athlon, etc.) has its own machine code Example machine code: 000000 00001 00010 00110 00000 100000 7Intro to Programming

8 Assembly Language Assembly language is a more human-friendly programming language that uses mnemonics in place of 0’s and 1’s in a program – Still difficult to program – Still hardware-dependent – Assembly programs are converted to machine code through an assembler Example assembly language code: SET r1, 10 STORE X, r1 8Intro to Programming

9 High-Level Language High-level languages allow programmers to write instructions that more closely resemble English language. – Much easier to learn and program – Hardware Independent: high-level programs can be compiled to run on many different computer platforms Example high-level code: var age = 30; 9Intro to Programming

10 Types of High-Level Languages High-level languages can be classified into different styles, based on how the language conceptualizes a computer program Two main categories of high-level languages are – Procedure-Oriented Languages – Object-Oriented Languages 10Intro to Programming

11 Procedure-Oriented Programs Procedure-oriented programs conceptualize a computer program as set of processes that call one another, each performing a series of sequential steps In procedure-oriented programs, programmer focuses on the specific steps (or actions) the program must take to solve a task – Very linear, step-by-step Intro to Programming11

12 Object-Oriented Programs Object-oriented programs conceptualize a computer program as a series of objects that send messages and pass data amongst each other In object-oriented programs, programmer focuses on the objects that interact to perform a task – Objects can be defined to represent real-world things Intro to Programming12

13 JavaScript Programming Language JavaScript is an Object-based, client-side web programming language – JavaScript is a high-level programming language – JavaScript is used in both a procedure-oriented and object-based way – Object-based, because it does not have all the features of an object-oriented language Intro to Programming13

14 Control Structures A computer program is a series of instructions that directs a computer to perform a task When writing programs, programmers need ways to control the order that instructions execute – This order of instructions is called the control flow All programming languages contain control structures to dictate the control flow of a program Intro to Programming14

15 Control Structures Every computer program uses one or more of the three basic control structures: sequence, selection and repetition All three control structures are used by all of us every day in solving problems Intro to Programming15

16 Control Structure: Sequence In order for each of us to complete a task, we understand that we have to do things one step at a time, in a specific order The sequence control structure directs a computer program to process the program instructions, one after the other, in the order listed on the program Every program uses the sequence control structure Intro to Programming16

17 Sequence Control Structure Example Imagine we need a program to draw one red lollipop 1.set color to black 2.draw vertical line 3.set color to red 4.draw circle 5.color circle Intro to Programming17

18 Control Structure: Repetition In order for each of us to complete a task, we often have to repeat some part of the task over and over The repetition control structure directs a computer program to repeatedly perform one or more action (loop) until some condition is met – Often represented with for, while or repeat-until loops Intro to Programming18

19 Repetition Control Structure Example Imagine we need a program to draw 30 red lollipops repeat 30 times: set color to black draw vertical line set color to red draw circle color circle Intro to Programming19

20 Repetition Control Structure Example (2) Imagine we need a program to eat a lollipop repeat until the lollipop is gone lick lollipop Intro to Programming20 Each instance of the loop (repetition of the process) is called an iteration Note indentation

21 Control Structure: Selection In order for each of us to complete a task, we often have to have to make decisions The selection control structure (also called decision structure) directs a computer program to make a decision, and then choose an action based on that decision – Often represented with if-then-else statements Intro to Programming21

22 Selection Control Structure Example Imagine we need a program to eat a lollipop and then display a message whether or not the lollipop was yummy or not repeat until the lollipop is gone lick lollipop if lollipop tastes yummy display lollipop is yummy else display lollipop is not yummy Intro to Programming22 The decision is based on a condition that evaluates to true or false

23 Algorithms On the previous slides, the set of instructions that solved the problems are called algorithms An algorithm is a set of step-by-step instructions that accomplish a task The algorithms for all computer programs contain one or more of the sequence, repetition and selection control structures. Intro to Programming23

24 In-Class Practice Write an algorithm to perform the following tasks (a) Get dressed in the morning (b) Make a cup of tea (c) Cross the street Intro to Programming24


Download ppt "Intro to Programming CST 200 - JavaScript. Objectives Define software Identify the different types of software Differentiate the different types of programming."

Similar presentations


Ads by Google