Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved.

Similar presentations


Presentation on theme: "Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved."— Presentation transcript:

1 Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 1 Chapter 1 An Introduction to Computers and Programming

2 Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 2 Computer Computer is a mechanical or electronic device that can effeciently store, retrieve, and manipulate large amounts of information at high speed and with great accuracy. Mainframe The IBM 360 are prominent in large companies and Universities. Minicomputer DEC creates the Minicomputer – about the size of a file cabinet. Supercomputer It is very powerful and specialized for massive computing problems used by corporations and government departments. Personal computer IBM PC, Apple Macintosh

3 Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 3 1.2 Computer Basics Components of a computer –CPU Central Processing Unit –Internal memory RAM (Random Access Memory) –Mass storage device – Hard disk drives, floppy disk, CD, DVD –Input devices – keyboard and mouse –Output Devices – monitor and printer 1 byte -> storage for one character 1024 bytes = 1 kilobyte (KB) 1024 KB = 1 megabyte (MB) 1024 MB = 1 gigabyte (GB) (Many people will approximate to steps of 1000, not 1024)

4 Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 4 1.3 Software and Programming Languages Application Software –Word Processors –Database s/w –Spreadsheets –Painting programs –Web browsers, email programs System Software –Operating systems – Windows, DOS, Linux, UNIX

5 Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 5 Programming Languages Machine Languages –1110100010101 111010101110 10111010110100 Assembly Languages –ADD A,B High-level Languages –Look more like English words and algebraic expressions –Examples of High Level Languages ADA BASIC C++ COBOL Java Pascal Visual Basic

6 Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 6 1.4 Programming Concepts Data and Data types Simple programming problem. Convert a price from British pounds into Dollars. Pseudocode Input the price of the item, PoundPrice, in pounds Compute the price of the item in dollars: Set DollarPrice = 1.62 * PoundPrice Write DollarPrice C++ Language cin >> PoundPrice DollarPrice = 1.62 * PoundPrice cout << DollarPrice

7 Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 7 Data Input, Variables and Data Types Input operations get data into the programs A user is prompted for the data to be entered –Write “Enter the price in pounds” –Input PoundPrice Data is input into a program variable. A named piece of memory whose value can change during the running of the program. The variable above is PoundPrice.

8 Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 8 Types of Data Numeric Data –Integer data, I.e., whole numbers, 10 25 -45 0 –Floating point data – have a decimal point 23.5 -5.0 Character data (alphanumerics) –All the characters you can type at the keyboard

9 Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 9 1.5 Data Processing and Output Set DollarPrice = 1.62 * PoundPrice The above statement is a processing statement. Take the value in the variable PoundPrice, multiply by 1.62, and set the variable DollarPrice to the result of the multiplication. Write DollarPrice Output the value in DollarPrice to the monitor. Assignment statements change the value in a variable –Set counter = counter + 1 –Take the value of counter, add 1, and store the result back in the same variable.

10 Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 10 Arithmetic Operations +Addition2 + 35 -Subtraction7 – 34 *Multiplication5 * 420 /Division12 / 34 ^Exponentiation2 ^ 38 Hierarchy of Operations Inside ( ) Exponents Multiply and divide Addition and subtraction

11 Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 11 Example of Hierarchy of Operations 3 * (6 + 2) / 12 – (7 – 5) ^ 2 * 3 = 3 * 8 / 12 – 2 ^ 2 * 3 ( ) first = 3 * 8 / 12 – 4 * 3 ^ next = 24 / 12 – 4 * 3 multiply and divide (left to right) = 2 – 12 add and subtract = -10

12 Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 12 Data Output Send information from the program to the screen, or printer, or disk file. Write DollarPrice the value of the variable is displayed on the screen and the cursor goes to the next line Write “The price in Dollars is”, DollarPrice The output looks like this: The price in Dollars is 162 Note that the text inside the “ ” is output to the user “as is,” and it is the value in the variable that is output.

13 Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 13 Pseudocode Language (Ch 1) Our pseudocode language will be expanded throughout the text. In this chapter we learned how to input, output, assign values to variables, and perform arithmetic calculations. InputAssignment Input Variable Set Variable = 10 Set Variable = AnotherVariable Output Arithmetic Operations Write “literal text”( ) ^ * / + - Write Variable Write “literal text”, Variable


Download ppt "Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved."

Similar presentations


Ads by Google