1 / 19

Computer Science: An Overview Eleventh Edition by J. Glenn Brookshear

Chapter 6: Programming Languages. Computer Science: An Overview Eleventh Edition by J. Glenn Brookshear. Generations of programming languages. Second-generation: Assembly language. A mnemonic system for representing machine instructions Mnemonic names for op-codes

oleg-garcia
Download Presentation

Computer Science: An Overview Eleventh Edition by J. Glenn Brookshear

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 6:Programming Languages Computer Science: An OverviewEleventh Edition by J. Glenn Brookshear

  2. Generations of programming languages

  3. Second-generation: Assembly language • A mnemonic system for representing machine instructions • Mnemonic names for op-codes • Identifiers: Descriptive names for memory locations, chosen by the programmer

  4. Assembly Language Characteristics • One-to-one correspondence between machine instructions and assembly instructions • Programmer must think like the machine • Inherently machine-dependent • Converted to machine language by a program called an assembler

  5. Machine language156C166D505630CEC000 Assembly languageLD R5, PriceLD R6, ShipChargeADDI R0, R5 R6ST R0, TotalCostHLT Program Example

  6. Third Generation Language • Uses high-level primitives • Similar to our pseudocode in Chapter 5 • Machine independent (mostly) • Examples: FORTRAN, COBOL • Each primitive corresponds to a sequence of machine language instructions • Converted to machine language by a program called a compiler

  7. The evolution of programming paradigms *different ways of thinking about communicating with the machine

  8. A function for checkbook balancing constructed from simpler functions Sample pseudocode: Imperative language: Total_credits <- sum of all Credits Temp_balance <- Old_balance + Total_credits Total_dedits <- sum of all Debits Balance <- Temp_balance – Total_debits Notice this code requires temporary storage to complete. Sample pseudocode: Functional language (LISP): (Find_diff (Find_sum Old_balance Credits) (Find-sum Debits)) This code uses information as it goes – no temporary storage needed for the final output.

  9. Programming Concepts Generally, a program consists of three categories: • Declarative • Imperative • Comments

  10. The composition of a typical imperative program or program unit

  11. Object-Oriented Languages • A class is the declaration of what makes up the object. • The object is an instance (specific occurrence) of the class. These attribute can be declared within the object. • Declarative statements • Variables and their data types (primitive, special) • Imperative statements • Methods – procedures CLASS CIRCLE OBJECTS

  12. Data Types Primitive • Integer: Whole numbers • Real (float): Numbers with fractions • Character: Symbols • Boolean: True/false

  13. Variable Declarations float Length, Width; int Price, Total, Tax; char Symbol; boolean Answer; • With assignment: int Price = 0; char Choice = ‘A’; boolean Answer = true; float Length = 12.5;

  14. Data Structures • The conceptual shape or arrangement of data deals with data structures. • Arrays • Aggregate type

  15. A two-dimensional array with two rows and nine columns

  16. The conceptual structure of the aggregate type (record) Employee

  17. Control Statements • Conditional statements • Loops • While • Until • For • Case (branching) • If-then-else

  18. The for loop structure and its representation in C++, C#, and Java

  19. Sample Code – C++

More Related