Presentation is loading. Please wait.

Presentation is loading. Please wait.

Outline 1 MECH 215 Programming for Mech. and Ind. Eng. I Prof. Chadi Assi CB-410-13, Ext. 5799

Similar presentations


Presentation on theme: "Outline 1 MECH 215 Programming for Mech. and Ind. Eng. I Prof. Chadi Assi CB-410-13, Ext. 5799"— Presentation transcript:

1 Outline 1 MECH 215 Programming for Mech. and Ind. Eng. I Prof. Chadi Assi CB-410-13, Ext. 5799 assi@ciise.concordia.ca

2 Outline 2 Course Highlight Lecture: Tuesday/Thursday8:45 — 10:00H-920 Office hours: Monday/Wednesday 2:30—3:30 Textbook: C++ How to Program/5e ISBN: 0131857576 by DEITEL&DEITEL Tutorials: (starts the week of September 11) TA ----J---- 15:15 16:05 FG-B055 Mr. Christopher Johnston (chrisjohnston600@hotmail.com)chrisjohnston600@hotmail.com TB ----J---- 15:15 16:05 H-613 Mr. Alborz Arzpeyna (a_arzpey@alcor.concordia.ca)a_arzpey@alcor.concordia.ca Lab: (starts the week of September 18) TI ----J---- 16:15 17:05 TBD TJ ----J---- 17:15 18:05 TBD TK ----J---- 16:15 17:05 TBD TL ----J---- 17:15 18:05 TBD

3 Outline 3 Grading and Rules 1. Homework should be submitted by e-mail to Ms. Alessandra Pollifrone (alessandrapollifrone@hotmail.com )alessandrapollifrone@hotmail.com 2. No late homework. No exception 4. Copying from the internet or any other source is unacceptable and considered cheating 5. Programming assignments should be given both hard and soft copy (hard copies are submitted to me in class; if you cannot make it to the class, e-mail your assignment) Midterms (2)26% Final60% Assignments14% Total100%

4 Outline 4 Course Outline 1. Introduction to Computers 2. Introduction to C++ Programming 3. Introduction to Classes and Objects 4. Control Statements Part 1 5. Control Statements Part 2 6. Functions 7. Arrays and Vectors 8. Pointers and Strings 9. Classes and Data Abstraction

5  2003 Prentice Hall, Inc. All rights reserved. 5 Introduction to Computers Outline -Introduction -What is a Computer? -Computer Organization -Evolution of Operating Systems -Machine Languages, Assembly Languages, and High-Level - Languages -History of C and C++ -C++ Standard Library -Visual C++ -Other High-Level Languages -Structured Programming -The Key Software Trend: Object Technology-- OOP -Basics of a Typical C++ Environment -Hardware Trends

6  2003 Prentice Hall, Inc. All rights reserved. 6 Introduction Software –Instructions to command computer to perform actions and make decisions Hardware (controlled by software) C++ is today’s most popular software development language –Standardized version of C++ United States –American National Standards Institute (ANSI) Worldwide –International Organization for Standardization (ISO) –Structured programming –Object-oriented programming

7  2003 Prentice Hall, Inc. All rights reserved. 7 What is a Computer? Computer –Device capable of performing computations and making logical decisions Computer programs –Sets of instructions that control computer’s processing of data Hardware –Various devices comprising computer Keyboard, screen, mouse, disks, memory, CD-ROM, processing units, … Software –Programs that run on computer

8  2003 Prentice Hall, Inc. All rights reserved. 8 Computer Organization Six logical units of computer 1.Input unit “Receiving” section Obtains information (e.g., data) from input devices –Keyboard, mouse, microphone, scanner, networks, … 2.Output unit “Shipping” section Takes information processed by computer Places information on output devices –Screen, printer, networks, … –Information used to control other devices

9  2003 Prentice Hall, Inc. All rights reserved. 9 Computer Organization Six logical units of computer 3.Memory unit Rapid access, relatively low capacity “warehouse” section Retains information from input unit –Immediately available for processing Retains processed information –Until placed on output devices Often called: memory or primary memory 4.Arithmetic and logic unit (ALU) “Manufacturing” section Performs arithmetic calculations and logic decisions

10  2003 Prentice Hall, Inc. All rights reserved. 10 Computer Organization Six logical units of computer 5.Central processing unit (CPU) “Administrative” section Supervises and coordinates other sections of computer 6.Secondary storage unit Long-term, high-capacity “warehouse” section Storage for –Inactive programs or data Secondary storage devices –Disks Longer to access than primary memory However, less expensive storage per unit than primary memory

11  2003 Prentice Hall, Inc. All rights reserved. 11 Computer Organization

12  2003 Prentice Hall, Inc. All rights reserved. 12 Main (or primary) Memory (1) It stores –programs –data –results

13  2003 Prentice Hall, Inc. All rights reserved. 13 Main Memory (2)  Memory: an ordered sequence of storage locations called memory cells  Every cell has a content (to store data) and an address -27.2 354 0.005 75.62 AddressContent 0 1024 1 1023 RTV0001 108 ADD1024 107 STR0005 109

14  2003 Prentice Hall, Inc. All rights reserved. 14 Main Memory (3) To access cell info: – each cell has a unique address Content of a cell may or may not be meaningful to our program (unless initialized or accessed by the program) A cell = –A grouping of smaller units called bytes A byte = –Amount of storage required to store a single character Number of bytes per cell varies

15  2003 Prentice Hall, Inc. All rights reserved. 15 Main Memory (4) A byte : –Composed of smaller units of storage called bits Binary: –a numbering system of two numbers 0 & 1 Bit = Binary digit: –Smallest element a computer can deal with (computers deal only with binary numbers) 0 1 2 3 4 5 6 7 byte a bit

16  2003 Prentice Hall, Inc. All rights reserved. 16 Evolution of Operating Systems (OS) Early computers –Single-user batch processing Only one job or task at a time Process data in groups (batches) Operating systems (developed to make the use of computers more convenient and improve the efficiency of computing systems) –Software systems –Manage transitions between jobs (early OS) –Increased throughput Amount of work computers process

17  2003 Prentice Hall, Inc. All rights reserved. 17 Evolution of Operating Systems As computers became more powerful, computing resources were not used more efficiently under the single-user batch processing model –Most of the time machine was waiting for slow input/output devices Multiprogramming –Many jobs or tasks sharing computer’s resources –“Simultaneous” operation of many jobs (i.e., sharing)

18  2003 Prentice Hall, Inc. All rights reserved. 18 Evolution of Operating Systems Timesharing –1960s –Special case of multiprogramming –Users access computer through terminals Devices with keyboards and screens Dozens, even hundreds of users –Perform small portion of one user’s job, then moves on to service next user Does not run all users programs simultaneously –Advantage: User receives almost immediate responses to requests (no pipelining of tasks)

19  2003 Prentice Hall, Inc. All rights reserved. 19 Machine Languages, Assembly Languages, and High-level Languages 1.Machine language Only language computer directly understands “Natural or native language” of computer Defined by hardware design –Machine-dependent (a particular machine language can be used only on one type of computer) Generally consist of strings of numbers –Ultimately 0s and 1s (binary) Instruct computers to perform elementary operations –One at a time Cumbersome for humans Example: +1300042774 +1400593419 +1200274027

20  2003 Prentice Hall, Inc. All rights reserved. 20 Machine Languages, Assembly Languages, and High-level Languages 2.Assembly language English-like abbreviations representing elementary computer operations Clearer to humans Incomprehensible to computers –Translator programs (assemblers) Convert from assembly to machine language Example: LOADBASEPAY ADD OVERPAY STORE GROSSPAY (addition of OVERPAY to BASEPAY and store result in GROSSPAY)

21  2003 Prentice Hall, Inc. All rights reserved. 21 Machine Languages, Assembly Languages, and High-level Languages 3.High-level languages Similar to everyday English, use common mathematical notations Single statements accomplish substantial tasks –Assembly language requires many instructions to accomplish simple tasks Translator programs (compilers) –Convert from high level to machine language Interpreter programs –Directly execute high-level language programs (w/out compiling into machine language) Example: grossPay = basePay + overTimePay

22  2003 Prentice Hall, Inc. All rights reserved. 22 History of C and C++ History of C –Evolved from two other programming languages BCPL and B –“Typeless” languages –Dennis Ritchie (Bell Laboratories) Added data typing, other features –Development language of UNIX –Hardware independent Portable programs –1989: ANSI standard –1990: ANSI and ISO standard published ANSI/ISO 9899: 1990

23  2003 Prentice Hall, Inc. All rights reserved. 23 History of C and C++ History of C++ –Extension of C –Provides capabilities for object-oriented programming (OOP) 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

24  2003 Prentice Hall, Inc. All rights reserved. 24 C++ Standard Library C++ programs –Built from pieces called classes and functions C++ standard library –Rich collections of existing classes and functions You can use them instead of re-writing them! “Building block approach” to creating programs –“Software reuse” Learning C++ essentially is –Learning the language itself –Learning how to use its functions and classes

25  2003 Prentice Hall, Inc. All rights reserved. 25 Visual C++ –Microsoft’s implementation of C++ Includes extensions Microsoft Foundation Classes (MFC) Common library –GUI, graphics, networking, multithreading, … –Shared among Visual Basic, Visual C++, C#.NET platform –Web-based applications Distributed to great variety of devices –Cell phones, desktop computers –Applications in disparate languages can communicate

26  2003 Prentice Hall, Inc. All rights reserved. 26 Other High-level Languages FORTRAN –Complex mathematical computations Scientific and engineering applications COBOL –COmmon Business Oriented Language –1959: computer manufacturers, government and industrial computer users –Precise and efficient manipulation of large amounts of data Commercial applications Pascal –Academic use

27  2003 Prentice Hall, Inc. All rights reserved. 27 Structured Programming Structured programming (1960s) –Disciplined approach to writing programs –Clear, easy to test and debug, and easy to modify A program: –a set of procedures (or functions) on a set of data values stored in the memory Emphasis on functions Function: –performs a sub task of the program –Abstraction of a behavior Separation of the behavior of a ‘thing’ from its representation or implementation

28  2003 Prentice Hall, Inc. All rights reserved. 28 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 OOP promotes thinking about software in a way that models the real world OOP supports good software engineering

29  2003 Prentice Hall, Inc. All rights reserved. 29 Object Oriented Programming, OOP Emphasis is on –the objects (data) and –how to manipulate them A program: –A network of objects with their attributes –Attributes = data and operations

30  2003 Prentice Hall, Inc. All rights reserved. 30 Object Oriented Programming, OOP Real-world problem: e.g., Automated banking system A Bank Account = a real object Class BankAccount { Data: int number; float balance; Operations: deposit(); wihtdraw(); } A class: –A definition of something (real thing) A class is an entity that defines the attributes of an object Attributes include data and operations (methods)

31  2003 Prentice Hall, Inc. All rights reserved. 31 Object Oriented Programming, OOP Class: – an entity that defines the attributes of an object Object: –An instance of a class A bank Account is a class –A particular bank account (yours) is an object Class Hierarchy Assume you want to define a new class similar to a predefined class Example: –Bank-Account Saving Account  International Account

32  2003 Prentice Hall, Inc. All rights reserved. 32 Basics of a Typical C++ Environment C++ systems consists of –Program-development environment –Language –C++ Standard Library

33  2003 Prentice Hall, Inc. All rights reserved. 33 Basics of a Typical C++ Environment Phases of C++ Programs: 1.Edit (any text editor; VC++ and other packages provide built in editor (a source code file usually ends with.cpp,.cc,.c, etc.)) 2.Preprocess (to include other files in the file being compiled, definition of symbolic constants, etc. all preprocessor directives start with #, e.g.: # include ) Loader Primary Memory Program is created in the editor and stored on disk. Preprocessor program processes the code. Loader puts program in memory. CPU takes each instruction and executes it, possibly storing new data values as the program executes. Compiler Compiler creates object code and stores it on disk. Linker links the object code with the libraries, creates a.out and stores it on disk Editor Preprocessor Linker CPU Primary Memory........................ Disk

34  2003 Prentice Hall, Inc. All rights reserved. 34 Basics of a Typical C++ Environment Phases of C++ Programs: 3.Compile (generate machine language) 4.Link (functions and data defined elsewhere: e.g., standard or private libraries ) 5.Load (load program from disk into memory) 6.Execute (CPU in charge) Loader Primary Memory Program is created in the editor and stored on disk. Preprocessor program processes the code. Loader puts program in memory. CPU takes each instruction and executes it, possibly storing new data values as the program executes. Compiler Compiler creates object code and stores it on disk. Linker links the object code with the libraries, creates a.out and stores it on disk Editor Preprocessor Linker CPU Primary Memory........................ Disk

35  2003 Prentice Hall, Inc. All rights reserved. 35 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

36  2003 Prentice Hall, Inc. All rights reserved. 36 Hardware Trends Capacities of computers –Approximately double every year or two –Memory used to execute programs –Amount of secondary storage Disk storage Hold programs and data over long term –Processor speeds Speed at which computers execute programs

37  2003 Prentice Hall, Inc. All rights reserved. 37 General Notes About C++ and This Book Book geared toward novice programmers –Stress programming clarity and simplicity Easier to understand, debug and test –C and C++ are portable languages Portability –C and C++ programs can run on many different computers


Download ppt "Outline 1 MECH 215 Programming for Mech. and Ind. Eng. I Prof. Chadi Assi CB-410-13, Ext. 5799"

Similar presentations


Ads by Google