Download presentation
Presentation is loading. Please wait.
1
Lecture 1: Intro to Computers Yoni Fridman 6/28/01 6/28/01
2
OutlineOutline ä What are computers? ä Hardware ä Software ä What is programming? ä Real-world algorithms ä Computer algorithms ä Storing data ä Decimal vs. binary ä Variables ä Programming languages ä Executing a program ä What are computers? ä Hardware ä Software ä What is programming? ä Real-world algorithms ä Computer algorithms ä Storing data ä Decimal vs. binary ä Variables ä Programming languages ä Executing a program
3
What Are Computers? ä Computers are “information processors.” ä They take in information – from the keyboard, from a mouse, through an electronic “eye,” etc. ä They do something with the information (i.e., process it). ä Then they spit out the results – through the monitor, by moving a robotic arm, etc. ä Computers are made up of hardware… ä The tangible parts of a computer. ä Monitor, mouse, memory cards, etc. ä And software. ä The programs that tell the computer what to do. ä Word processor, video games, etc. ä Computers are “information processors.” ä They take in information – from the keyboard, from a mouse, through an electronic “eye,” etc. ä They do something with the information (i.e., process it). ä Then they spit out the results – through the monitor, by moving a robotic arm, etc. ä Computers are made up of hardware… ä The tangible parts of a computer. ä Monitor, mouse, memory cards, etc. ä And software. ä The programs that tell the computer what to do. ä Word processor, video games, etc.
4
HardwareHardware ä Processors – the “brains” of the computer. ä CPU (central processing unit), graphics processors, math processors. ä Memory – the ability to store information. ä Main memory, or RAM, stores information while the computer is on. ä Secondary memory (hard drive, floppy disk, etc.) stores information indefinitely. ä Peripheral devices – provide an interface to the outside world. ä Input devices – mouse, keyboard. ä Output devices – Monitor, printer. ä Processors – the “brains” of the computer. ä CPU (central processing unit), graphics processors, math processors. ä Memory – the ability to store information. ä Main memory, or RAM, stores information while the computer is on. ä Secondary memory (hard drive, floppy disk, etc.) stores information indefinitely. ä Peripheral devices – provide an interface to the outside world. ä Input devices – mouse, keyboard. ä Output devices – Monitor, printer.
5
HardwareHardware Input Output CPU Main Memory Secondary Memory
6
SoftwareSoftware ä Tells the hardware what to do. ä Operating Systems (OS) ä Collection of programs that interact directly with the hardware. ä DOS, Windows, MacOS, Unix, Linux. ä Applications ä A program not involved in the OS that performs a particular task. ä Word processor, drawing application, web browser, video game. ä Anything written by you in Java. ä Tells the hardware what to do. ä Operating Systems (OS) ä Collection of programs that interact directly with the hardware. ä DOS, Windows, MacOS, Unix, Linux. ä Applications ä A program not involved in the OS that performs a particular task. ä Word processor, drawing application, web browser, video game. ä Anything written by you in Java.
7
SoftwareSoftware ä An OS acts as a bridge between applications and hardware. ä An application sends a request to the OS, which then tells the hardware what to do. ä An OS acts as a bridge between applications and hardware. ä An application sends a request to the OS, which then tells the hardware what to do. Hardware Application OS Software
8
What Is Programming? ä Programming is entering a series of commands, or instructions, that tell the computer what to do. ä The instructions must: 1. Be discrete, i.e., not overlap or blend together. 2. Be precisely defined, not vague or ambiguous. ä These instructions combine to form an algorithm. ä The process of designing and writing an algorithm is called programming. ä Programming is entering a series of commands, or instructions, that tell the computer what to do. ä The instructions must: 1. Be discrete, i.e., not overlap or blend together. 2. Be precisely defined, not vague or ambiguous. ä These instructions combine to form an algorithm. ä The process of designing and writing an algorithm is called programming.
9
Real-World Algorithms Algorithms exist in the real world, and they’re written in natural languages (e.g., English). For example, a recipe in a cookbook or instructions for a board game. But, natural language algorithms lack the precision needed for a computer to understand. For example, “stir until thick.” A computer can’t make judgments, and needs perfectly precise instructions. Algorithms exist in the real world, and they’re written in natural languages (e.g., English). For example, a recipe in a cookbook or instructions for a board game. But, natural language algorithms lack the precision needed for a computer to understand. For example, “stir until thick.” A computer can’t make judgments, and needs perfectly precise instructions.
10
Computer Algorithms ä Computer algorithms are written in programming languages (e.g., Java). ä Such algorithms are precise enough for the computer – they require no judgment. ä Example: Compute the remainder of 23/7. 1. Subtract 7 from 23. 2. If the result is less than 7, then that’s your answer. Stop. 3. Otherwise, subtract 7 from the result. 4. Go back to step 2. ä Computer algorithms are written in programming languages (e.g., Java). ä Such algorithms are precise enough for the computer – they require no judgment. ä Example: Compute the remainder of 23/7. 1. Subtract 7 from 23. 2. If the result is less than 7, then that’s your answer. Stop. 3. Otherwise, subtract 7 from the result. 4. Go back to step 2.
11
Storing Data ä Data refers to information that can be stored, for example, numbers, letters, or names. ä 1, 23, 10.75, x, hello, Tom ä All computers really do is manipulate data. ä This data must be stored in the computer – how? ä Data refers to information that can be stored, for example, numbers, letters, or names. ä 1, 23, 10.75, x, hello, Tom ä All computers really do is manipulate data. ä This data must be stored in the computer – how?
12
Decimal vs. Binary ä We usually think of numbers in decimal (0-9). ä Computers only know binary (0 and 1). ä Example: 25 in decimal equals 11001 in binary. ä Binary is longer, but it’s the only way computers can store info. ä Not only numbers, but also letters and all other data are stored in the computer in binary. ä One binary digit is called a bit. ä A bit can’t store much, so computers group 8 bits together into what is called a byte – like a word. ä We usually think of numbers in decimal (0-9). ä Computers only know binary (0 and 1). ä Example: 25 in decimal equals 11001 in binary. ä Binary is longer, but it’s the only way computers can store info. ä Not only numbers, but also letters and all other data are stored in the computer in binary. ä One binary digit is called a bit. ä A bit can’t store much, so computers group 8 bits together into what is called a byte – like a word.
13
VariablesVariables ä Variables are locations within an algorithm that store data. ä For example, the variables x and y are usually used to store coordinates in 2D. ä Remember our example: Remainder of 23/7. 1. Subtract 7 from 23. 2. If the result is less than 7, then that’s your answer. Stop. 3. Otherwise, subtract 7 from the result. 4. Go back to step 2. ä This algorithm would contain three variables – one for “7”, one for “23”, and one for the result. ä Variables are locations within an algorithm that store data. ä For example, the variables x and y are usually used to store coordinates in 2D. ä Remember our example: Remainder of 23/7. 1. Subtract 7 from 23. 2. If the result is less than 7, then that’s your answer. Stop. 3. Otherwise, subtract 7 from the result. 4. Go back to step 2. ä This algorithm would contain three variables – one for “7”, one for “23”, and one for the result.
14
Programming Languages ä Machine languages manipulate data in a very basic, primitive way. ä They’re composed of bits, and almost impossible to understand. ä Assembly languages are composed of commands rather than bits, but still difficult to understand. ä High-level languages are much more similar to English. ä Programmers write using high-level languages, and the computer translates these to an assembly language and then to a machine language. ä Examples: Java, C++, BASIC, FORTRAN, and Pascal. ä Machine languages manipulate data in a very basic, primitive way. ä They’re composed of bits, and almost impossible to understand. ä Assembly languages are composed of commands rather than bits, but still difficult to understand. ä High-level languages are much more similar to English. ä Programmers write using high-level languages, and the computer translates these to an assembly language and then to a machine language. ä Examples: Java, C++, BASIC, FORTRAN, and Pascal.
15
Executing a Program ä The text of a program written in Java, for example, is called source code. ä The computer can’t directly understand source code – it’s not executable. ä There are two methods to execute a program: 1. Compile it: A compiler first makes sure that the source code obeys the rules of the programming language. It then translates the source code to machine language and stores this in a file. This file can now be executed. 2. Interpret it: An interpreter executes the machine instructions corresponding to the source code. ä The text of a program written in Java, for example, is called source code. ä The computer can’t directly understand source code – it’s not executable. ä There are two methods to execute a program: 1. Compile it: A compiler first makes sure that the source code obeys the rules of the programming language. It then translates the source code to machine language and stores this in a file. This file can now be executed. 2. Interpret it: An interpreter executes the machine instructions corresponding to the source code.
16
HomeworkHomework ä Go to the campus store and buy the textbook and three floppy disks. ä Read: ä Sections 1.1, 1.3, 1.4, and 1.5 to review today’s lecture. ä Sections 2.1, 2.4, 2.5, 2.6, 2.7, and 2.8 for tomorrow’s lecture. ä HW1 out today, due Monday. ä Written part: Write a precise real-world algorithm to light a match. ä Programming part: Getting started with Visual J++. ä Go to the campus store and buy the textbook and three floppy disks. ä Read: ä Sections 1.1, 1.3, 1.4, and 1.5 to review today’s lecture. ä Sections 2.1, 2.4, 2.5, 2.6, 2.7, and 2.8 for tomorrow’s lecture. ä HW1 out today, due Monday. ä Written part: Write a precise real-world algorithm to light a match. ä Programming part: Getting started with Visual J++.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.