20
CPSC- 120 CPSC- 120 Principle of Principle of Computer Computer Science I Science I Computer = Hardware + Computer = Hardware + Software Software

CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Embed Size (px)

Citation preview

Page 1: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

CPSC- 120 CPSC- 120 Principle of ComputerPrinciple of Computer Science I Science I

Computer = Hardware + Computer = Hardware + SoftwareSoftware

Page 2: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

HardwareHardware

Main MemoryMain MemorySecondary MemorySecondary MemoryCentral Processing Unit (CPU)Central Processing Unit (CPU)Input DevisesInput DevisesOutput DevisesOutput Devises

Page 3: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Main MemoryMain Memory

Random Access Memory (RAM)Random Access Memory (RAM) storing information and programsstoring information and programs information such as numbers, information such as numbers,

names, lists, pictures names, lists, pictures An ordered sequence of storage An ordered sequence of storage

locations called memory celllocations called memory cell each memory cell has associated each memory cell has associated

with it a unique addresswith it a unique address

Page 4: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Secondary MemorySecondary Memory

Additional storage capability on Additional storage capability on most computer such as a disk drivemost computer such as a disk drive

hard disk, floppy disk, CD hard disk, floppy disk, CD inexpensiveinexpensive more information can be stored more information can be stored

measured by megabyte or measured by megabyte or gigabytesgigabytes

Page 5: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Central Processing Unit Central Processing Unit (CPU)(CPU)

Control computer operations Control computer operations Perform arithmetic and logical Perform arithmetic and logical

operationsoperations each operation is performed less than each operation is performed less than

one millionth of a secondone millionth of a second To process a program, CPU To process a program, CPU

• fetches each instructionfetches each instruction• decodes the instructiondecodes the instruction• executes the instructionexecutes the instruction

Page 6: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Input and Output DevicesInput and Output Devices

OutputOutput• Monitor, PrinterMonitor, Printer

Input Input • Keyboard, Mouse Keyboard, Mouse

Page 7: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

SoftwareSoftware

Operating Systems- - Operating Systems- - UNIX, WindowsUNIX, Windows

Application Programs - - Application Programs - - Word Processor, Word Processor, SpreadsheetSpreadsheet

Software Development Tools - - Software Development Tools - - compilercompiler, , editor editor

Page 8: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Steps in the Software Development Steps in the Software Development MethodMethod

Problem SpecificationProblem Specification AnalysisAnalysis DesignDesign Test PlanTest Plan Implementation or codingImplementation or coding TestingTesting

Page 9: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Case StudyCase Study

Refer to page 21Refer to page 21

Page 10: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Programming languagesProgramming languages

Machine LanguagesMachine Languages Assembly LanguagesAssembly Languages High-Level LanguagesHigh-Level Languages

Page 11: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

WITH Ada.Text_IO;WITH Ada.Text_IO;PRODECURE Hello ISPRODECURE Hello IS------------------------------------------------------------------------------------------------------------------------------------------ A very simple program; it is just displays a greeting.-- A very simple program; it is just displays a greeting.-- -- -- ------------------------------------------------------------------ ----------------------------------------------------------------BEGIN -- HelloBEGIN -- Hello

Ada.Text_IO.Put(Item => “Hello there. “);Ada.Text_IO.Put(Item => “Hello there. “);Ada.Text_IO.Put(Item => “We hope you enjoy studying Ada.Text_IO.Put(Item => “We hope you enjoy studying

Ada!”);Ada!”);Ada.Text_IO.New_Line;Ada.Text_IO.New_Line;

END Hello;END Hello;

Example Ada ProgramExample Ada Program

Page 12: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Chapter 3Chapter 3

The General Structure of Ada The General Structure of Ada ProgramsPrograms

Page 13: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Displaying Initials ProgramDisplaying Initials Program

WITH Ada.Text_IO;PROCEDURE Hello_Initials IS-------------------------------------------------------

-------| Requests, then displays, user's first and last

initials.--|-------------------------------------------------------

-----

Initial1 : Character; -- objects that hold initials Initial2 : Character;

Page 14: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Cont.Cont.

BEGIN -- Hello_Initials-- Prompt for (request user to enter) user's initials Ada.Text_IO.Put(Item => "Enter your two initials> "); Ada.Text_IO.Get(Item => Initial1); Ada.Text_IO.Get(Item => Initial2);

-- Display user's initials, with a greeting Ada.Text_IO.Put(Item => "Hello "); Ada.Text_IO.Put(Item => Initial1); Ada.Text_IO.Put(Item => Initial2); Ada.Text_IO.Put(Item => ". Enjoy studying Ada!"); Ada.Text_IO.New_Line;

END Hello_Initials;

Page 15: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Reserve Words and Reserve Words and IdentifiersIdentifiers

Reserve WordsReserve Words

With With

ProcedureProcedure

ISIS

BeginBegin

END END

Page 16: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Predefined IdentifiersPredefined Identifiers

Ada.Text_IOAda.Text_IO

PutPut

New_LineNew_Line

CharacterCharacter

GetGet

Page 17: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Displaying the User’s Displaying the User’s NameName

WITH Ada.Text_IO;PROCEDURE Hello_Name IS-------------------------------------------------------

-------------------| Requests, then displays, user's name--| -------------------------------------------------------

-----------------

FirstName: String(1..10); -- object to hold user's name

Page 18: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Cont.Cont.

BEGIN -- Hello_Name -- Prompt for (request user to enter) user's name Ada.Text_IO.Put (Item => "Enter your first name, exactly 10 letters."); Ada.Text_IO.New_Line; Ada.Text_IO.Put (Item => "Add spaces at the end if it's shorter.> "); Ada.Text_IO.Get(Item => FirstName); -- Display the entered name, with a greeting Ada.Text_IO.Put(Item => "Hello "); Ada.Text_IO.Put(Item => FirstName); Ada.Text_IO.Put(Item => ". Enjoy studying Ada!"); Ada.Text_IO.New_Line;END Hello_Name;

Page 19: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software

Ada’s CapabilitiesAda’s Capabilities

Control StructuresControl Structures Data StructuresData Structures System StructuresSystem Structures

Page 20: CPSC- 120 Principle of Computer Science I Computer = Hardware + Software