270 likes | 357 Views
Chapter 0: Introduction. Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake. A Brief History of Computers. Calculators are used to increase speed and accuracy of numerical computations The abacus has roots dating back over 5,000 years
E N D
Chapter 0:Introduction Extended Prelude to Programming Concepts & Design, 3/e byStewart Venit and Elizabeth Drake
A Brief History of Computers • Calculators are used to increase speed and accuracy of numerical computations • The abacus has roots dating back over 5,000 years • Mechanical calculators have been relatively commonplace since late 19th century • What is a computer? • A mechanical or electronic device • Stores, retrieves, manipulates large amounts of data (information) at high speed, with great accuracy • Does not need human intervention • Carries out instructions from a program
The Pioneers • Mid-1800’s: Charles Babbage built the Analytical Engine • made from axels and gears that could store and process 40 digit numbers: mechanical • 1940: Howard Aitken at Harvard, and Atanasoff and Berry at Iowa State created Mark I, an electronic computer. • It could not act on intermediate results. • 1945: Mauchly and Eckert at U. Pennsylvania built the ENIAC (Electronic Numerical Integrator and Calculator) • Weighed 33 tons, 17,000 vacuum tubes • Performed up to 5000 additions per second
Early Computers • 1945 – 1950’s: First generation computers • used vacuum tubes to do internal switching needed for computations • 1955: about 300 computers in the world built mostly by IBM and Remington Rand, based on vacuum tubes. • Late 1950s: invention of the transistor was one of most important inventions of 20th Century • computers based on the transistor are the first solid-state computers. • Early 1960’s: DEC created the minicomputer (Servers) – about the size of a file cabinet. • Used small packages of transistors called integrated circuits • Mainframes, such as the IBM 360 are prominent in large companies and Universities.
The Personal Computer • 1970s: The personal computer becomes available with invention of the microchip • 1974: The microchip, along with the invention of the microprocessor led to creation of first personal computer • Bill Gates and Paul Allen founded Microsoft Corporation • Stephen Wozniak and Steven Jobs founded Apple Computer, Inc.
Computers Today • Currently: • PCs: 95% use Microsoft Windows operating system with a huge array of available software • Minicomputers (servers) are still popular with small business and universities. • Mainframes are in use at large corporations. • Supercomputers are very powerful and specialized • Used for massive computing problems by big corporations and government departments.
Components and Operations • Hardware: equipment, or devices • Software: programs that contain instructions for the computer • Hardware and software: the two major • components of any computer system • Major operations in a computer: • Input • Processing • Output
Components and Operations • Input devices: allow data to enter the computer • Mouse, keyboard, scanner • Processing: working on the data; such as: • Organizing data • Checking data for accuracy • Mathematical or other manipulations on data • Central Processing Unit (CPU): hardware that performs the tasks
Components and Operations • Output devices: provide data to the user • Printer, monitor, speakers • Programming language: special language containing instructions for the computer • Visual Basic, Java, C#, C++, COBOL • Syntax: the rules governing word usage and punctuation in the language • Machine language: a language that controls the computer’s on/off circuitry • Compiler or interpreter: software that translates programming languages to machine language
Computer Basics • Components of a computer • Central Processing Unit (CPU) • Internal memory • RAM (Random Access Memory) • ROM (Read Only Memory) • Mass storage devices • Magnetic, optical, and solid-state • Input devices such as keyboard and mouse • Output devices such as monitor and printer • Computer functionality: Input – process - output
Central Processing Unit (CPU) • Often called the brain of the computer • Carries out program instructions (memory) • Performs arithmetic and logical operations (ALU) • Controls other computer components (operating system) • Consists of millions of transistors on a single microchip that plug into the motherboard
Internal Memory (RAM and ROM) • ROM: read-only memory • Contains instructions used by computer during startup • Cannot be altered by computer user • RAM: random-access memory • Is a “scratch pad” for user as he or she works • Can be read from and written to • Operating System/Applications reside
Memory • Two storage categories: internal and external • Internal storage: • Main memory, random access memory (RAM) • Located inside the computer system • Volatile: contents are lost when power goes down • External storage: • Persistent: contents are relatively permanent • Floppy drive, hard drive, flash media, magnetic tape • Located outside the computer system
Basic Units of Memory • 1 bit (0 or 1) • 4 bits = nibble • 1 byte = 8 bits = 2 nibbles • Is the storage for one character • 1 word = 4 bytes • 1 K = 1 KB = 1 kilobyte = 1,0240 bytes = 210 bytes • Kilo = 1,000 : 1 KB = 1,000 bytes • 1 Meg = 1 megabyte (MB) = 1 million = 1024 KB • 1 GB = 1 gigabyte (GB) = 1024 MB = 1,000,000,000 • Many people approximate to steps of 1000, not 1024
Mass Storage Devices • Magnetic storage • Hard disks, floppy disks, zip drives • Hard disks are internal, others are external • Optical storage • CDs and DVDs • Solid-state storage • Flash drives plug into a USB port
Input and Output Devices • Input • Keyboard, mouse, digital pen, modem, wireless Internet connection, touch screen, joy sticks, and more • Output • Monitor, printer, speakers, modem, wireless Internet connection, and more
Software and Programming Languages • System Software • Operating systems – Windows, DOS, Linux, UNIX, dll, utilities, drivers • Application Software • Word Processors (MS Word) • Database Managers (Access) • Spreadsheets (Excel) • Photo Editors • Web browsers, email programs (Netscape)
Programming Languages • Machine Languages • 0110110111110111 0000000100000000 0000000100000000 • Assembly Languages • One programmer instruction converted to 1 machine level instruction • ADD A,B • High-level Languages • Looks more like English words and algebraic expressions • Examples of high level languages • Programmer instruction converted to many machine level ADA BASIC C++ FORTRAN COBOL Java Pascal Visual Basic
Coding the program: • Select the programming language • Write the instructions • Using software to translate the program into machine language: • Programmers write instructions in English-like high-level languages • Compilers or interpreters change the programs into low-level machine language that can be executed • Syntax errors are identified by the compiler or interpreter
One Machine Language Instruction Many machine Language Instructions Machine Language Generation Programmer written computer code Programmer written computer code Translator (Interpreter) Program(browser) Compiler Assembler FUNCTIONBrowsersnetscapeMS ExplorerJavascriptPHPASP .exe file Execute Execute MS Word, Windows XP, MS Excel, Vista, MS Explorer
Writing Programs • To write a program in a high-level language, you need: • Appropriate software • A text editor to type and edit program statements • A debugger to help find errors in program code • A compiler or interpreter to translate the program into machine language
Components and Operations • A program must be free of syntax errors to be run, or executed, on a computer • The program will not compile or be translated • Usually a message will point out the offending instruction • To function properly, the logic must be correct • The program will still execute • The output may be incorrect • The program may exit prematurly • The program may ABEND (Abnormal Termination) • The program may execute with no errors/problems
Error Types • Logic errors are more difficult to locate than syntax errors Syntax: the rules governing word usage and punctuation in the language(format, recipe, formula)
Data Hierarchy • Data hierarchy: ordering of data types by size • Character: single symbol (letter, number, special symbol) • “A”, “7”, “$” • Field: group of characters forming a single data item • “Smith” • Record: a group of related fields • Customer record containing name and address fields • File: a group of related records • Customer file, containing all customer records • Database: collection of related files, called tables, that serve the information needs of the organization
Variables • Variable: a memory location whose contents can vary; also called an identifier • Each programming language has it own rules for naming identifiers, including: • Legal characters • Maximum length • Use of upper or lower case • Variable name must be a single word, but can be formed from several words • rate, interestRate, interest_rate • Constant: value does not change • Literal: is use of data itself
Understanding Data Types • Two basic data types: • Text • Numeric • Numeric data stored by numeric variables • Text data stored by string, text, or character variables • Constants: • Values that do not change while the program is running • Have identifiers, and can be used like variables for calculations, but cannot be assigned new values
Understanding Data Types (continued) • Some programming languages implement several numeric data types, such as: • Integer: whole numbers only • Floating-point: fractional numeric values with decimal points • Character or string data is represented as characters enclosed in quotation marks • “x”, “color” • Data types must be used appropriately