190 likes | 316 Vues
What is programming?. Steps to solve a problem. Repeatable by executing or “doing” the steps again. Write a program. Problem solve phase Implement phase (Maintenance phase) Program VCR to tape American Idol. Problem Solving. Solve the problem before writing any program Pseudo Code
E N D
What is programming? • Steps to solve a problem. • Repeatable by executing or “doing” the steps again. UWP - Landgraf Some slides are from Dr. Qi Yang's notes
Write a program • Problem solve phase • Implement phase (Maintenance phase) Program VCR to tape American Idol UWP - Landgraf Some slides are from Dr. Qi Yang's notes
Problem Solving • Solve the problem before writing any program • Pseudo Code If score is positive Add score to Total Else Display an error message UWP - Landgraf Some slides are from Dr. Qi Yang's notes
Algorithm • Instructions on how to do something • Details • If you leave out steps… Can you write an algorithm to set an alarm clock? UWP - Landgraf Some slides are from Dr. Qi Yang's notes
What is a programming language? • Set of instructions, rules, and symbols known by a computer that can be interpreted by the computer to solve a problem. UWP - Landgraf Some slides are from Dr. Qi Yang's notes
High Level Programming Languages C++ Java BASIC COBOL English Like Easy to Read and Write (Compared with low level) C++ Code Example Total = Total + Score; UWP - Landgraf Some slides are from Dr. Qi Yang's notes
Low Level Programming Languages Total = Total + Score; Machine Code 10010110 00000000 10100101 Assembly Code Add AX, Score UWP - Landgraf Some slides are from Dr. Qi Yang's notes
Programming Steps • Create source code file: Lab0.cpp • Compile to machine code: Lab0.obj • Link to executable program: Lab0.exe • Run Lab0.exe UWP - Landgraf Some slides are from Dr. Qi Yang's notes
What is a computer? Network CPU Output Input MEMORY Storage UWP - Landgraf Some slides are from Dr. Qi Yang's notes
Hardware • CPU • Memory • Keyboard • Monitor • Disk • … UWP - Landgraf Some slides are from Dr. Qi Yang's notes
Problem-SolvingTechniques • ASK for HELP!!!! • Look for things that are familiar • Given salary, compute a 10% salary increase. • Given the price of a product, compute a 10% price increase • Solve by analogy • I know how to rollerblade. • This is similar to ice skating. • Means/Ends Analysis • If I’m on one side of the river, how can I get to the other side? UWP - Landgraf Some slides are from Dr. Qi Yang's notes
Problem-Solving Techniques • Divide and conquer • Build a house with electrician, carpenter, plumber etc. • Building-block approach • Components of a sound system • Merging solutions • What things can be done at the same time? UWP - Landgraf Some slides are from Dr. Qi Yang's notes
Mental Blocks • Fear of starting • Just do it • Algorithmic problem solving • Not always easy • May fail (it will make you stronger) UWP - Landgraf Some slides are from Dr. Qi Yang's notes
How to Store Data in Computer Bit Electronic Device On / Off Value: 1 / 0 Byte 8 bits Possible combinations 256 28 UWP - Landgraf Some slides are from Dr. Qi Yang's notes
1 0 1 1 0 0 1 1 How to Store Data in Computer Binary Number 27 26 25 24 23 22 21 20 • 27 + 23 + 22 + 21 + 20 • + 8 + 4 + 2 + 1 • Decimal Number: 143 UWP - Landgraf Some slides are from Dr. Qi Yang's notes
0 0 0 0 1 0 0 1 How to Store Data in Computer Binary Number 65 Character ASCII (EBCDIC) ASCII Character is See Appendix D pp. 695-696 UWP - Landgraf Some slides are from Dr. Qi Yang's notes
How to Store Data in Computer Word 2 bytes (16 bits) Double Word 4 bytes (32 bits) Integers Binary Numbers Characters ASCII Unicode (p. 34 footnote) Float Numbers? Negative numbers? UWP - Landgraf Some slides are from Dr. Qi Yang's notes
How to Store Data in Computer KB 1024 Bytes 210 MB 1024 * 1024 Bytes 220 GB 1024 * 1024 * 1024 Bytes 230 TB… UWP - Landgraf Some slides are from Dr. Qi Yang's notes