Upload
cory-russell
View
217
Download
2
Embed Size (px)
Citation preview
CPSC- 120 CPSC- 120 Principle of ComputerPrinciple of Computer Science I Science I
Computer = Hardware + Computer = Hardware + SoftwareSoftware
HardwareHardware
Main MemoryMain MemorySecondary MemorySecondary MemoryCentral Processing Unit (CPU)Central Processing Unit (CPU)Input DevisesInput DevisesOutput DevisesOutput Devises
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
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
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
Input and Output DevicesInput and Output Devices
OutputOutput• Monitor, PrinterMonitor, Printer
Input Input • Keyboard, Mouse Keyboard, Mouse
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
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
Case StudyCase Study
Refer to page 21Refer to page 21
Programming languagesProgramming languages
Machine LanguagesMachine Languages Assembly LanguagesAssembly Languages High-Level LanguagesHigh-Level Languages
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
Chapter 3Chapter 3
The General Structure of Ada The General Structure of Ada ProgramsPrograms
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;
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;
Reserve Words and Reserve Words and IdentifiersIdentifiers
Reserve WordsReserve Words
With With
ProcedureProcedure
ISIS
BeginBegin
END END
Predefined IdentifiersPredefined Identifiers
Ada.Text_IOAda.Text_IO
PutPut
New_LineNew_Line
CharacterCharacter
GetGet
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
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;
Ada’s CapabilitiesAda’s Capabilities
Control StructuresControl Structures Data StructuresData Structures System StructuresSystem Structures