Docsity

c++ how to program 4th edition pdf, Slides of Programming Languages

Partial preview of the text

Download c++ how to program 4th edition pdf and more Slides Programming Languages in PDF only on Docsity!

CHAPTER 1 – INTRODUCTION TO

COMPUTERS AND C++ PROGRAMMING

LANGUAGE

Reben KURDA

Technical Information System Eng. Department Erbil Polytechnic University

Chapter 1 – Introduction to Computers and

C++ Programming

Outline 1.1 Introduction 1.2 What is a Computer? 1.3 Computer Organization 1.4 Evolution of Operating Systems 1.5 Personal Computing, Distributed Computing and Client/Server Computing 1.6 Machine Languages, Assembly Languages, and High-Level Languages 1.7 History of C and C++ 1.8 C++ Standard Library 1.9 Java 1.10 Visual Basic, Visual C++ and C# 1.11 Other High-Level Languages 1.12 Structured Programming 1.13 The Key Software Trend: Object Technology 1.14 Basics of a Typical C++ Environment 1.15 Hardware Trends

1.6 Machine Languages, Assembly

Languages, and High-level Languages

  • Three types of computer languages

1. Machine language

  • Only language computer directly understands
  • “Natural language” of computer
  • Defined by hardware design
    • Machine-dependent
  • Generally consist of strings of numbers
    • Ultimately 0s and 1s
  • Instruct computers to perform elementary operations
    • One at a time
  • Cumbersome for humans
  • Example: + + +

1.6 Machine Languages, Assembly

Languages, and High-level Languages

  • Three types of computer languages

2. Assembly language

  • English-like abbreviations representing elementary computer operations
  • Clearer to humans
  • Incomprehensible to computers
    • Translator programs (assemblers)
      • Convert to machine language
  • Example: LOAD BASEPAY ADD OVERPAY STORE GROSSPAY

1.6 Machine Languages, Assembly

Languages, and High-level Languages

3. High-level languages

What is a programming language?

■ A tool for instructing machines ■ A notation for algorithms ■ A means for communication among programmers ■ A tool for experimentation ■ A means for controlling computer-controlled gadgets ■ A means for controlling computerized devices ■ A way of expressing relationships among concepts ■ A means for expressing high-level designs ■ All of the above! ■ And more

1.6 Machine Languages, Assembly

Languages, and High-level Languages

3. High-level languages

Why do we design and evolve languages?

There are many diverse applications areas

  • No one language can be the best for everything

Programmers have diverse backgrounds and skills

  • No one language can be best for everybody

Problems change

  • Over the years, computers are applied in new areas and to new problems

Computers change

  • Over the decades, hardware characteristics and tradeoffs change

Progress happens

  • Over the decades, we learn better ways to design and implement languages

These are the steps recommended for the

process of writing a program

Problem-Solving Phase

1 Analysis and specification. Understand (define) the problem and what the sold must do.

2 General solution (algorithm). Develop a logical sequence of steps that solves the problem.

3 Verify. Follow the steps exactly to see if the solution really does solve the problem

Implementation Phase

1 Concrete solution (program). Translate the algorithm into a programming language.

2 Test. Have the computer follow the instructions. Then manually check the results.

  • If you find errors, analyze the program and the algorithm to determine the source of the errors

Maintenance Phase

1 Use. Use the program.

2 Maintain. Modify the program to meet changing requirements or to correct any errors that show up in using it.

These are the steps recommended for the

process of writing a program

1.7 History of C and C++

  • History of C++
    • Extension of C
    • Early 1980s: Bjarne Stroustrup (Bell Laboratories)
    • “Spruces up” C
    • Provides capabilities for object-oriented programming
      • Objects: reusable software components
        • Model items in real world
      • Object-oriented programs
        • Easy to understand, correct and modify
    • Hybrid language
      • C-like style
      • Object-oriented style
      • Both

1.8 C++ Standard Library

  • C++ programs
    • Built from pieces called classes and functions
  • C++ standard library
    • Rich collections of existing classes and functions
  • “Building block approach” to creating programs
    • “Software reuse”

1.13 The Key Software Trend: Object

Technology

  • Objects
    • Reusable software components that model real world items
    • Meaningful software units
      • Date objects, time objects, paycheck objects, invoice objects, audio objects, video objects, file objects, record objects, etc.
      • Any noun can be represented as an object
    • More understandable, better organized and easier to maintain

than procedural programming

  • Favor modularity
    • Software reuse
      • Libraries
        • MFC (Microsoft Foundation Classes)

1.14 Basics of a Typical C++ Environment

  • C++ systems
    • Program-development environment
    • Language
    • C++ Standard Library

1.14 Basics of a Typical C++ Environment

  • Input/output
    • cin
      • Standard input stream
      • Normally keyboard
    • cout
      • Standard output stream
      • Normally computer screen
    • cerr
      • Standard error stream
      • Display error messages

1.19 General Notes About C++

and This Book

  • Book geared toward novice programmers
    • Stress programming clarity
    • C and C++ are portable languages
  • Portability
    • C and C++ programs can run on many different computers
  • Compatibility
    • Many features of current versions of C++ not compatible

with older implementations