8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.

Slides:



Advertisements
Similar presentations
Programming Languages and Paradigms
Advertisements

Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Introduction to Programming Lesson 1. Objectives Skills/ConceptsMTA Exam Objectives Understanding Computer Programming Understand computer storage and.
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
High-Level Programming Languages
Chapter 8 High-Level Programming Languages Nell Dale John Lewis.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
An Introduction to Programming with C++ Fifth Edition Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
11/1/06 1 Hofstra University, CSC005 Chapter 8 (Part 3) High Level Programming Languages.
Chapter 2 Data Types, Declarations, and Displays
Chapter 8 Arrays and Strings
JavaScript, Third Edition
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Chapter 8: Introduction to High-Level Language Programming Invitation to Computer Science, C++ Version, Fourth Edition.
Object-Oriented Design and High-Level Programming Languages
Basic Elements of C++ Chapter 2.
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Invitation to Computer Science 5th Edition
1 Variables, Constants, and Data Types Primitive Data Types Variables, Initialization, and Assignment Constants Characters Strings Reading for this class:
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
 Value, Variable and Data Type  Type Conversion  Arithmetic Expression Evaluation  Scope of variable.
Lesson 2 McManus COP  Computational ◦ problems involving some kind of mathematical processing  Logical ◦ Problems involving relational or logical.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
High-Level Programming Languages: C++
Chapter 8 High-Level Programming Languages. 2 Compilers High-level language A language that provides a richer (more English like) set of instructions.
Chapter 9 Object-Oriented Design and High-Level Programming Languages.
CIS Computer Programming Logic
Tutorial 11 Using and Writing Visual Basic for Applications Code
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Flow of Control. 2 Control Structures Control structure: An instruction that determines the order in which other instructions in a program are executed.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Chapters 7, 8, & 9 Quiz 3 Review 1. 2 Algorithms Algorithm A set of unambiguous instructions for solving a problem or subproblem in a finite amount of.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
1 CSC103: Introduction to Computer and Programming Lecture No 6.
CPS120 Introduction to Computer Science Iteration (Looping)
S2008Final_part1.ppt CS11 Introduction to Programming Final Exam Part 1 S A computer is a mechanical or electrical device which stores, retrieves,
CPS120: Introduction to Computer Science
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
JAVA 0. HAFTA Algorithms FOURTH EDITION Robert Sedgewick and Kevin Wayne Princeton University.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
CPS120: Introduction to Computer Science Decision Making in Programs.
CPS120: Introduction to Computer Science Functions.
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
Introduction to Java Java Translation Program Structure
Chapter 8 High-Level Programming Languages. 2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Programming in Java (COP 2250) Lecture 4 Chengyong Yang Fall, 2005.
1 Program Development  The creation of software involves four basic activities: establishing the requirements creating a design implementing the code.
CPS120: Introduction to Computer Science Variables and Constants.
FUNCTIONS. Midterm questions (1-10) review 1. Every line in a C program should end with a semicolon. 2. In C language lowercase letters are significant.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
© 2004 Pearson Addison-Wesley. All rights reserved August 27, 2007 Primitive Data Types ComS 207: Programming I (in Java) Iowa State University, FALL 2007.
Primitive Data Types August 28, 2006 ComS 207: Programming I (in Java)
Object Oriented Programming
Multiple variables can be created in one declaration
The Selection Structure
High Level Programming Languages
Low Level Programming Languages
Flow of Control.
The Data Element.
The Data Element.
COMPUTING.
Presentation transcript:

8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions that makes the programmer’s life even easier

8-2 Compilers Figure 8.1 Compilation process

8-3 Programming Language Paradigms Figure 8.2 Portability provided by standardized languages versus interpretation by Bytecode

8-4 Programming Language Paradigms Figure 8.2 Portability provided by standardized languages versus interpretation by Bytecode

8-5 What Programs Do Assignment Input / Output Sequence Selection Deciding which action to take Iteration (looping) Repeating an action Abstraction Event Management

8-6 Assignment statement Assignment statement An action statement (not a declaration) that says to evaluate the expression on the right-hand side of the symbol and store that value into the place named on the left-hand side Named constant A location in memory, referenced by an identifier, that contains a data value that cannot be changed

Assignment Statement Page

8-8 Input/Output Structures The key to the processing is in the data type that determines how characters are to be converted to a bit pattern (input) and how a bit pattern is to be converted to characters (output) We do not give examples of input/output statements because the syntax is often quite complex and differs so widely among high-level languages

8-9 Selection Statements The if statement allows the program to test the state of the program variables using a Boolean expression Page 243

8-10 Selection Statements Figure 8.3 Flow of control of if statement

8-11 Selection Statements

8-12 case Statement For convenience, many high-level languages include a case (or switch) statement Allows us to make multiple-choice decisions easier, provided the choices are discrete Page 246

8-13 Looping Statements The while statement is used to repeat a course of action Let’s look at two distinct types of repetitions

8-14 Looping Statements Count-controlled loops –Repeat a specified number of times –Use of a special variable called a loop control variable Figure 8.4 Flow of control of while statement

8-15 Looping Statements Event-controlled loops –The number of repetitions is controlled by an event that occurs within the body of the loop itself Page 249

8-16 Looping Statements Count-controlled loops

8-17 Looping Statements –Event-controlled loops Page 249

8-18 Subprogram Statements We can give a section of code a name and use that name as a statement in another part of the program When the name is encountered, the processing in the other part of the program halts while the named code is executed

8-19 Subprogram Statements There are times when the calling unit needs to give information to the subprogram to use in its processing A parameter list is a list of the identifiers with which the subprogram is to work, along with the types of each identifier placed in parentheses beside the subprogram name

8-20 Subprogram Statements Figure 8.5 Subprogram flow of control

8-21 Subprogram Statements Parameters Identifiers listed in parentheses beside the subprogram declaration; sometimes they are called formal parameters Arguments Identifiers listed in parentheses on the subprogram call; sometimes they are called actual parameters

8-22 Subprogram Statements Page 253

8-23 Recursion Recursion The ability of a subprogram to call itself Each recursive solution has at least two cases –Base case The case to which we have an answer –General case The case that expresses the solution in terms of a call to itself with a smaller version of the problem For example, the factorial of a number is defined as the number times the product of all the numbers between itself and 0: N! = N * (N  1)!

8-24 Event Processing Event processing The concept that input and output can be accomplished through windows on the screen –Clicking has become a major form of input to the computer –Mouse clicking is not within the sequence of the program –A user can click a mouse at any time during the execution of a program –This type of processing is called asynchronous

8-25 One way to keep from making mistakes Strong typing The requirement that only a value of the proper type can be stored into a variable Data type A description of the set of values and the basic set of operations that can be applied to values of the type

8-26 Declarations Declaration A statement that associates an identifier with a variable, an action, or some other entity within the language that can be given a name so that the programmer can refer to that item by name

Declarations 8-26

8-28 Integers The range varies depending upon how many bytes are assigned to represent an integer value Some high-level languages provide several integer types of different sizes Operations that can be applied to integers are the standard arithmetic and relational operations

8-29 Reals Like the integer data type, the range varies depending on the number of bytes assigned to represent a real number Many high-level languages have two sizes of real numbers The operations that can be applied to real numbers are the same as those that can be applied to integer numbers

8-30 Characters It takes one byte to represent characters in the ASCII character set Two bytes to represent characters in the Unicode character set Our English alphabet is represented in ASCII, which is a subset of Unicode

8-31 Characters Applying arithmetic operations to characters doesn’t make much sense Comparing characters does make sense, so the relational operators can be applied to characters The meaning of “less than” and “greater than” when applied to characters is “comes before” and “comes after” in the character set

8-32 Boolean The Boolean data type consists of two values: true and false Not all high-level languages support the Boolean data type If a language does not, then you can simulate Boolean values by saying that the Boolean value true is represented by 1 and false is represented by 0

8-33 Strings A string is a sequence of characters considered as one data value For example: “This is a string.” –Containing 17 characters: one uppercase letter, 12 lowercase letters, three blanks, and a period The operations defined on strings vary from language to language –They include concatenation of strings and comparison of strings in terms of lexicographic order

8-34 Arrays An array is a named collection of homogeneous items in which individual items are accessed by their place within the collection –The place within the collection is called an index

8-35 Arrays Figure 8.8 Array variable tenThings accessed from 0..9

8-36 Composite Data Types Records –A record is a named heterogeneous collection of items in which individual items are accessed by name –The elements in the collection can be of various types

8-37 Composite Data Types Page 258

8-38 Composite Data Types Page 259