Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER 1 Overview of Programming and Problem Solving.

Similar presentations


Presentation on theme: "CHAPTER 1 Overview of Programming and Problem Solving."— Presentation transcript:

1

2 CHAPTER 1 Overview of Programming and Problem Solving

3 What is a computer program? What is programming? l PROGRAM –list of instructions to be performed by computer l PROGRAMMING –planning sequence of steps for computer to follow.

4 List the three phases of developing computer programs. l 1) Problem-Solving phase –Analysis & Specification Define the problem Define what the solution must do –General solution (algorithm) steps to solve problem –Verify Does solution actually solve the problem?

5 3 phases of developing pgms l 2) Implementation –Translate algorithm into programming language –Program tested –Errors corrected

6 3 phases of developing pgms l 3) MAINTENANCE CHANGE?? –Correction defects –Adaptation changes in ext. environment –Enhancement extend functionality

7 A Tempting Shortcut? GOAL THINKING CODE REVISE DEBUG TEST CODE Shortcut?

8 What is an algorithm? l step-by-step procedure l solves problem in finite time l e.g., Washing hair, recipes, CHILTON'S

9 What is a programming language? l Set of –rules –symbols –keywords l used to construct a program. ALGORITHM LANGUAGE PROGRAM

10 What is documentation? l Text and comments l making program easier l for others to understand, l use, and modify.

11 Define Bit, Byte. l Bit –a binary digit, 1 or 0 l Byte –a group of bits, usually 8

12 11 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

13

14 Bits, Binary System, Byte l All computer data is stored as a sequence of bits. l The binary (base-two) number system represents computer bits as numbers. l A byte can store 256 different combinations. 256 = 2 8

15 Contrast machine language, assembly language, and high- level languages. l Machine language –binary coded instructions –used directly by computer l C70604010500

16 l Assembly language –low level language –mnemonics –represents machine language instructions for a particular computer MOV X, 5

17 l High Level language –statements resemble spoken languages –or mathematical notation l Pascal, FORTRAN, COBOL, C++, BASIC, C

18 l C++: X = 5; l Assembly:mov word ptr [x], 5 l Machine:C70604010500 l Binary:110001110000011000000100 l 000000010000010100000000

19 List advantages of high-level programming language? l Easier to use –(closer to English / Math) l Solve problems faster l Portable –(may run on many machines)

20 What does a compiler do? an assembler? l A compiler translates a high level language program into machine code. l An assembler translates an assembly language program into machine code. C++ Pgm MS Visu C++ Compiler PC machine language

21 Three C++ Program Stages other code from libraries, etc. other code from libraries, etc. written in machine language written in machine language written in machine language written in machine language written in C++ written in C++ via compilervia linker SOURCEOBJECT EXECUTABLE myprog.cppmyprog.objmyprog.exe

22 Origins of C++ l C –Dennis Ritchie developed at Bell Labs –Late 1960s –Systems programming language (90% Unix) l C++ –Bjarne Stroustrup of Bell Labs –1985 –Object-oriented features added

23 Some C++ History l 1972 : Dennis Ritchie at Bell Labs designs C and 90% of UNIX is then written in C l Late 70’s : OOP becomes popular l Bjarne Stroustrup at Bell Labs adds features to C to form “C with Classes” l 1983 : Name C++ first used l 1998 : ISO/ANSI standardization of C++

24 List four basic control structures used in programming. l SEQUENCE –series of statements –one statement executed after another –(wash hair algorithm)

25 SEQUENCE Statement...

26 l SELECTION –executes statements depending upon certain conditions

27 SELECTION (branch) IF Condition THEN Statement1 ELSE Statement2 Statement1 Statement Statement2 Condition... True False

28 l LOOP –repeats statements while certain conditions are met

29 LOOP (repetition) Statement Condition... False True WHILE Condition DO Statement1

30 l PROCEDURE –breaks up a program into smaller subprograms

31 SUBPROGRAM (function) SUBPROGRAM1... SUBPROGRAM1 a meaningful collection of SEQUENCE, SELECTION, LOOP, SUBPROGRAM

32 What is Computer Science? The Computing Curriculum 1991 (ACM/IEEE) l Algorithms and Data Structures l Architecture l Artificial Intelligence and Robotics l Database and Information Retrieval l Human-Computer Communication l Numerical and Symbolic Computation l Operating Systems l Programming Languages l Software Engineering l Social and Professional Context

33

34 Drawing in Processing Automatic creation of display window Window has a coordinate system for drawing

35 Let's draw a point: point() point(x, y) – draws a point at the location x, y Try it in Processing: point(50, 50) Unexpected token: null Compiler errors appear in the bottom pane All lines must be terminated with a semicolon ; Try drawing several points


Download ppt "CHAPTER 1 Overview of Programming and Problem Solving."

Similar presentations


Ads by Google