Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS101 - Introduction To Computer Concepts1 Purpose of Computer programs The purpose of writing a program is to solve a problem, perform a repetitious task.

Similar presentations


Presentation on theme: "CS101 - Introduction To Computer Concepts1 Purpose of Computer programs The purpose of writing a program is to solve a problem, perform a repetitious task."— Presentation transcript:

1 CS101 - Introduction To Computer Concepts1 Purpose of Computer programs The purpose of writing a program is to solve a problem, perform a repetitious task or manage data The general steps in computer programming and general problem solving are: –Understand the problem or task requirements –Break down the problem or requirements into manageable pieces –Design a solution addressing all aspects of the task –Consider alternatives to the solution and refine it –Implement the solution –Test the solution and fix any problems that exist

2 CS101 - Introduction To Computer Concepts2 Computer Program Life Cycle

3 CS101 - Introduction To Computer Concepts3 Software projects can fail because the developer didn't really understand the problem or task at hand The software development did not gather all the details and cases relevant to the task The complexity of the system caused the solution to become confusing and disconnected. Software development team did not use the correct technology tools Common Program Development Problems

4 CS101 - Introduction To Computer Concepts4 Computer Program Structure Chart

5 CS101 - Introduction To Computer Concepts5 Flowchart Computer Program Flow Chart

6 CS101 - Introduction To Computer Concepts6 Computer –Performs computations and makes logical decisions –Millions / billions times faster than human beings Computer programs –Sets of instructions by which a computer processes data Hardware –Physical devices of computer system Software –Programs that run on computers  2003 Prentice Hall, Inc. All rights reserved. (modified by Evan Korth) Components of a Computer System

7 CS101 - Introduction To Computer Concepts7 A CPU is on a chip called a microprocessor It continuously follows the fetch-decode-execute cycle: fetch Retrieve an instruction from main memory decode Determine what the instruction is execute Carry out the instruction Central Processing Unit

8 CS101 - Introduction To Computer Concepts8 The CPU contains: Arithmetic / Logic Unit Registers Control Unit Small storage areas Performs calculations and makes decisions Coordinates processing steps CPU Components

9 CS101 - Introduction To Computer Concepts9 System Software –Interface between hardware and computer users –Does not serve the needs of solving user’s problem Application Software –Accessed directly by users to serve their needs Computer Programs - Software Types

10 CS101 - Introduction To Computer Concepts10 System Software –Operating System Windows, Linux, Unix, Mac OS User Interface (UI) File and database management Communication protocols (e.g., TCP/IP) –System support software System Utilities Disk utilities (format, error-checking, defragmentation) System Software

11 CS101 - Introduction To Computer Concepts11 Application Software –General-purpose software Used for more than one application Word processors, spreadsheets, DBMS, CAD systems Solve a variety of problems –Application-specific software Used for only one application Accounting systems Space-shuttle control systems

12 CS101 - Introduction To Computer Concepts12 Programming Languages A programming language specifies the words and symbols that we can use to write a program A programming language employs a set of rules that dictate how the words and symbols can be put together to form valid program statements The actual statements in a language, something like sentences, are referred to as “source code”

13 CS101 - Introduction To Computer Concepts13 Language Levels There are four programming language levels: –machine language –assembly language –high-level language (many specific to a academic discipline) –fourth-generation language Each type of CPU has its own specific machine language The other levels were created to make it easier for people to work with programs.

14 CS101 - Introduction To Computer Concepts14 Programming Language Example Source Code StatementLanaguage Add one to my-total (COBOL) ADD 1,@my-total(Basic Assemble Language) mytotal = mytotal + 1 (Visual Basic, FORTRAN) mytotal ++ (C++) set mytotal [expr mytotal +1] (PERL) All of the above statements accomplish the same thing

15 CS101 - Introduction To Computer Concepts15 Running Programming Languages A program must be translated into machine language before it can be executed on a particular type of CPU A compiler is a software tool which translates source code into a specific target language Often, that target language is the machine language for a particular CPU type

16 CS101 - Introduction To Computer Concepts16 The Program Translation Process Terms to Know: Source Code Object Code Executable Source Object Executable Translator Linker Loader other programs

17 CS101 - Introduction To Computer Concepts17 Programming Translation Example Source Code StatementLevel Add one to my-total Application ST 1, R5Assembly ST my-total, R6 ADD R5,R6 ST R5,my-total 10011011 0001 0101 Machine Language for “ST 1,R5” Instruction Code for ST (Store) The number 1 in base 2 The number 5 in base 2 indicating CPU Register 5

18 CS101 - Introduction To Computer Concepts18 Syntax and Semantics The syntax rules of a language define how we can put together symbols, reserved words, and identifiers to make a valid program The semantics of a program statement define what that statement means (its purpose or role in a program) A program that is syntactically correct is not necessarily logically (semantically) correct A program will always do what we tell it to do, not what we meant to tell it to do

19 CS101 - Introduction To Computer Concepts19 Language Components Lexicon –All legal words in the language –Meaning and type Syntax –grammar rules Semantics –meaning of command

20 CS101 - Introduction To Computer Concepts20 Basic Program Development errors Edit and save program Compile program Execute program and evaluate results

21 CS101 - Introduction To Computer Concepts21 Errors A program can have three types of errors 1.The compiler will find syntax errors and other basic problems (compile-time errors) 1.If compile-time errors exist, an executable version of the program is not created 2.A problem can occur during program execution, such as trying to divide by zero, which causes a program to terminate abnormally (run- time errors) 3.A program may run, but produce incorrect results, perhaps using an incorrect formula (logical errors)

22 CS101 - Introduction To Computer Concepts22 Debugging Techniques Step through programs Check variable values Use tools to stop program running when a value is reached Print out information from within your program

23 CS101 - Introduction To Computer Concepts23 EditorsEditors AssemblersAssemblers DebuggersDebuggers CompilersCompilers LinkersLinkers LoadersLoaders InterpretersInterpreters Integrated Development Environments (IDEs) combine several of the above programming tools Programming Tools and Support

24 CS101 - Introduction To Computer Concepts24 Example of High-Level IDE (Visual Basic.NET) Learn more about me in CS508 !!!

25 CS101 - Introduction To Computer Concepts25 Program Text Editors Word processors format the appearance of the text Text editors –Format the spacing between words for legibility –Ideal for structured languages –Text is the same font size Examples –DOS – Edit –Windows – Notepad, Wordpad –Unix / Linux – ed, vi, emacs IDEs –MS Visual C++, Symantec Visual Cafe

26 CS101 - Introduction To Computer Concepts26 Interpreters Translates source code instructions into machine language and executes it one statement at a time Disadvantages –Longer to execute, particularly bad for loops –Uses more memory Advantage –Faster testing and code modification Examples of interpreted languages –Java, BASIC, LISP

27 CS101 - Introduction To Computer Concepts27 Interpreter vs. Compiler Resources during executionInterpreterCompiler Contents in memory Interpreter/compilerYesNo Source codePartialNo Executable codeYes CPU cycles Translation operationsYesNo Library linkingYesNo Application programYes

28 CS101 - Introduction To Computer Concepts28 Where does memory fit in? Computer Processing Components Major components of a computer –CPU or Central Processing Unit –Primary (internal) memory –Secondary (external memory) –Control Unit –Arithmetic Logic Unit –Input devices –Output devices Control Unit Arithmetic- Logic Unit Main Memory Input Devices Output Devices Network External Memory CPU

29 CS101 - Introduction To Computer Concepts29 CPU and Main Memory Central Processing Unit Main Memory Chip that executes program commands Intel Pentium 4 or Sun ultraSPARC III Processor Primary storage area for programs and data that are in active use Synonymous with RAM (Random Access Memory)

30 CS101 - Introduction To Computer Concepts30 Purposes of Memory Hold instructions so the CPU can fetch your program and execute it Keep your data available to the CPU to use when executing an instruction Work with the CPU to perform some really fast arithmetic

31 CS101 - Introduction To Computer Concepts31 Memory Areas Main Memory –Internal, primary, random access memory (RAM) –Stores instructions and data Cache memory –Smaller quantity of high speed memory, speed meaning quicker for the CPU to access Registers –Specific high speed memory locations used repeatedly by instructions –Helps in arithemetic

32 CS101 - Introduction To Computer Concepts32 Memory Structure Main memory is divided into many memory locations (or cells) 9278 9279 9280 9281 9282 9283 9284 9285 9286 Each memory cell has a numeric address, which uniquely identifies it

33 CS101 - Introduction To Computer Concepts33 Analog vs. Digital There are two basic ways to store and manage data: Analog –continuous, in direct proportion to the data represented –music on a record album - a needle rides on ridges in the grooves that are directly proportional to the voltages sent to the speaker Digital –the information is broken down into pieces, and each piece is represented separately –music on a compact disc - the disc stores numbers representing specific voltage levels sampled at specific times

34 CS101 - Introduction To Computer Concepts34 Digital Information is Stored in Memory Computers store all information digitally: –numbers –text –graphics and images –video –audio –program instructions In some way, all information is digitized - broken down into pieces and represented as numbers

35 CS101 - Introduction To Computer Concepts35 Representing Text Data Digitally For example, every character is stored as a number, including spaces, digits, and punctuation Corresponding upper and lower case letters are separate characters H i, H e a t h e r. 72 105 44 32 72 101 97 116 104 101 114 46 These numbers can be found in a decoding table

36 CS101 - Introduction To Computer Concepts36 Binary Numbers Once information is digitized, it is represented and stored in memory using the binary number system A single binary digit (0 or 1) is called a bit Devices that store and move information are cheaper and more reliable if they have to represent only two states A single bit can represent two possible states, like a light bulb that is either on (1) or off (0) Permutations of bits are used to store values

37 CS101 - Introduction To Computer Concepts37 Bit Permutations 1 bit 0101 2 bits 00 01 10 11 3 bits 000 001 010 011 100 101 110 111 4 bits 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Each additional bit doubles the number of possible permutations

38 CS101 - Introduction To Computer Concepts38 Bit Permutations Each permutation can represent a particular item There are 2 N permutations of N bits Therefore, N bits are needed to represent 2 N unique items 2 1 = 2 items 2 2 = 4 items 2 3 = 8 items 2 4 = 16 items 2 5 = 32 items 1 bit ? 2 bits ? 3 bits ? 4 bits ? 5 bits ? How many items can be represented by

39 CS101 - Introduction To Computer Concepts39 Storing Information 9278 9279 9280 9281 9282 9283 9284 9285 9286 Large values are stored in consecutive memory locations10011010 Each memory cell stores a set number of bits (usually 8 bits, or one byte)

40 CS101 - Introduction To Computer Concepts40 Look Back at our Example 9278 9279 9280 9281 9282 9283 9284 9285 9286 These two locations represent one instruction ST 1,R500011010 10011011 0001---- 10111011 These three locations represent one instruction LOAD R1,mytotal00000101 00000000 location of mytotal value = 5 SymbolLocation mytotal9285 Memory Symbol Table Memory Used for Instructions Memory Used for Data -------- The ---- in 9281 and 0282 would be the string of 0,1 that equal 9285 in base 2 R1..R9 are special memory areas of the CPU much like your MEM button on a calculator

41 CS101 - Introduction To Computer Concepts41 Programs and Memory Summary The computer will actually be looking at a set of zeroes and ones when executing instructions or working with data Programmers think of data in terms of numbers (to add / multiply) and characters (letters, or numbers that are not added -like zip codes) Programmers use variables as a way to set aside memory and keep data there during the program When setting up a variable, the programmer will say how much much memory is needed and whether the memory will hold numbers or letters Each variable you used in a program will be assigned a real memory address when the program runs or executes

42 CS101 - Introduction To Computer Concepts42 Storage Capacity Every memory device has a storage capacity, indicating the number of bytes it can hold Capacities are expressed in various units: KB2 10 = 1024 MB2 20 (over 1 million) GB2 30 (over 1 billion) TB2 40 (over 1 trillion) UnitSymbolNumber of Bytes kilobyte megabyte gigabyte terabyte


Download ppt "CS101 - Introduction To Computer Concepts1 Purpose of Computer programs The purpose of writing a program is to solve a problem, perform a repetitious task."

Similar presentations


Ads by Google