Presentation is loading. Please wait.

Presentation is loading. Please wait.

Main Memory Central Processor Unit Keyboard Input Device Secondary Memory Monitor Printer Output Devices.

Similar presentations


Presentation on theme: "Main Memory Central Processor Unit Keyboard Input Device Secondary Memory Monitor Printer Output Devices."— Presentation transcript:

1

2

3

4

5

6

7

8

9 Main Memory Central Processor Unit Keyboard Input Device Secondary Memory Monitor Printer Output Devices

10 MEMORY - (data and instructions) 1. Each cell has a VALUE and ADDRESS 2. One value at a time 3. Move a COPY to a new location 4. Size of memory varies byte = 8 bits word = multiple of bytes usually transparent to you (not important here)

11 MEMORY - (data and instructions cont.) Computer Memory with 1000 cells Words have multiple BYTES BYTES have multiple (8) BITS

12 Central Processing Unit I/O Devices Secondary Memory Disk or Tape Slower Larger-> Reasons for different types Cheaper

13 What do Computers Do? (example like p.8 of notes) 1. Fetch instruction (add) 2. Decode instruction 3. Fetch operands ( NMBR1, NMBR2 ) 4. Perform operation ( NMBR1 + NMBR2 ) 5. Store results (put sum in location for Sum ) REPEAT In other words - they always(only) run programs What happens when you turn it on? Runs bootstrap program Bootstrap program loads OS (unix) Unix loads other programs (including “shell”) “shell” will read commands load program run program wait for the next command

14 What does “unix” do for you? 1. Manage resources  Who runs and how long  Who uses devices such as disk 2. Provide Protection  Who uses machine  Users only have access to what they need 3. Provide programs you need  Compilers  Building programs  File utilities (create, delete, rename, etc)  Printing utilities Your lab instructor will show you how to use unix

15 Entering, Compiling and Running a Program 1. Use an editor (like “emacs”) to enter the program and save it on the disk. 2. Use a compiler (like “g++”) to translate the program into machine language 3. Link libraries with your program (auto) 4. Execute the machine language version (like “emacs”, “g++” or “a.out”)

16 MODELS for learning The process of learning about computers is one of building a MENTAL MODEL of what happens. As you become more knowledgeable about computers your model will become more sophisticated and more accurate. Accept the limitations of your models, but question your instructor if you have any suspicion that your model of what is happening is wrong. Language Problems Realize that English itself is very INaccurate. YOU make it reasonable by associating the MOST REASONABLE interpretation to the statements. Learning to be precise with c++ will take practice!

17 Overview of c++ Objectives 1. Recognizing the non-linear nature of program complexity the need for simple interfaces that OOP/OOD is a long-term goal 2. Understanding that obtaining a program that “works” is insufficient. Style is an important part of programming.

18 Complexity of Software Size of Program Complexity LINEARNON-LINEAR 1. Stay in this area 2. Break large systems into small pieces 3. Interfaces of the pieces become a problem

19 Tools Building your program from good tools (software) makes your job less complicated REUSABILITY of code has been historically LOW OOP/OOD increases REUSABILITY!

20 OOD (Object-Oriented Design) OOP (Object-Oriented Programming) The DESIGN process is fairly independent of the language as long as the language is object-oriented. C++ is used in our course because of its widespread acceptance support not necessarily because it is the best OOP language.

21 Sample c++ program. Version 1. Convert Square Meters to Square Yards. (INPUT ->)PROCESS -> OUTPUT Calculate the answerOutput the answer #include void main () { cout << 20 * 1.196; //20 SqMeters to SqYards } Problems 1. Always uses the same numbers (solves the same problem). NOT GENERAL! 2. Only numbers on output! NEEDS LABELLING! 3. Observer does not understand what we're doing! NEEDS DOCUMENTATION! drake> g++ version1.C drake> a.out 23.92 drake>

22 Same Program. Version 2. #include void main() {// declare variables and constants const float meters_to_yards = 1.196; float size_in_sqmeters; size_in_sqmeters = 20; float size_in_sqyards; // calculate square yards size_in_sqyards = size_in_sqmeters * meters_to_yards; // output square yards cout << "The size in square yards is "; cout << size_in_sqyards << "\n"; } drake> g++ version2.C drake> a.out The size in square yards is 23.92 drake> GOOD -> Provided DOCUMENTATION and LABELLING BAD ->Still NOT GENERAL

23 Version 3. #include void main() {// declare variables and constants const float meters_to_yards = 1.196; float size_in_sqmeters, size_in_sqyards; // read size in square meters cin >> size_in_sqmeters; // calculate square yards size_in_sqyards = size_in_sqmeters * meters_to_yards; // output square yards cout << "The size in square yards is "; cout << size_in_sqyards << "\n"; } drake> g++ version3.C drake> a.out 20 The size in square yards is 23.92 drake> a.out 10 The size in square yards is 11.96 drake> STILL NEED to PROMPT USER!

24 Version 4. #include void main() {// declare variables and constants const float meters_to_yards = 1.196; float size_in_sqmeters, size_in_sq_yards; // read size in square meters cout "; cin >> size_in_sqmeters; // calculate square yards size_in_sqyards = size_in_sqmeters * meters_to_yards; // output square yards cout << "The size in square yards is "; cout << size_in_sqyards << "\n"; } drake> g++ version4.C drake> a.out Enter the number of square meters -> 20 The size in square yards is 23.92 drake> a.out Enter the number of square meters -> 10 The size in square yards is 11.96 drake> DONE!


Download ppt "Main Memory Central Processor Unit Keyboard Input Device Secondary Memory Monitor Printer Output Devices."

Similar presentations


Ads by Google