Low-Level Programming Languages, Pseudocode and Testing Chapter 6.

Slides:



Advertisements
Similar presentations
Low-Level Programming Languages and Pseudocode
Advertisements

CS107: Introduction to Computer Science Lecture 2 Jan 29th.
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
1 Algorithms Algorithm A set of unambiguous instructions for solving a problem or subproblem in a finite amount of time using a finite amount of data Why.
Low-Level Programming Languages and Pseudocode Chapter 6.
Slides modified by Erin Chambers Problem Solving and Algorithm Design.
Programming Dr. Abraham Most slides are from your textbook.
Chapter 6 Problem Solving and Algorithm Design. 2 Phase Interactions.
Low-Level Programming Languages and Pseudocode Chapter 6.
Chapter 6 Problem Solving and Algorithm Design. 2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2 - Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 2 - Problem Solving
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Low-Level Programming Languages
Program Design and Development
Chapter 7 Low-Level Programming Languages. 2 Chapter Goals List the operations that a computer can perform Discuss the relationship between levels of.
Chapter 7 Low-Level Programming Languages Nell Dale John Lewis.
Algorithms. Introduction Before writing a program: –Have a thorough understanding of the problem –Carefully plan an approach for solving it While writing.
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 1 Program Design
Problem Solving and Algorithm Design
Chapter 2: Algorithm Discovery and Design
Slides modified by Erin Chambers Problem Solving and Algorithm Design, part 2.
Computer Science 101 Introduction to Programming.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Low-Level Programming Languages and Pseudocode
Quiz # 2 Chapters 4, 5, & 6.
Simple Program Design Third Edition A Step-by-Step Approach
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Chapter 6 Problem Solving and Algorithm Design. 2 Problem Solving Problem solving The act of finding a solution to a perplexing, distressing, vexing,
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Chapter 6 Problem Solving and Algorithm Design. 2 Chapter Goals Apply top-down design methodology to develop an algorithm to solve a problem Define the.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
The Programming Process Define the problem* Make or buy software? Design the program * Code (write) the program Test (debug) the program Document the.
Introduction to Computer Application (IC) MH Room 517 Time : 7:00-9:30pm.
Computer Operations A computer is a programmable electronic device that can store, retrieve, and process data Data and instructions to manipulate the data.
Chapter 7 Low-Level Programming Languages. 2 Chapter Goals List the operations that a computer can perform Discuss the relationship between levels of.
Chapter 7 Low-Level Programming Languages. 2 Chapter Goals List the operations that a computer can perform Discuss the relationship between levels of.
Chapter 7 Low-Level Programming Languages (slides modified by Erin Chambers)
Chapter 7 Low-Level Programming Languages Nell Dale John Lewis.
Chapter 7 Low-Level Programming Languages Nell Dale John Lewis.
Chapter 6 Problem Solving and Algorithm Design. 2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 1 An Introduction to Visual Basic.NET and Program Design.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
ALGORITHMS AND FLOWCHARTS
Algorithm and Ambiguity
An Introduction to Visual Basic .NET and Program Design
Programming Fundamentals (750113) Ch1. Problem Solving
Problem Solving and Algorithm Design
Programming We have seen various examples of programming languages
Algorithm and Ambiguity
Algorithms and Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Presentation transcript:

Low-Level Programming Languages, Pseudocode and Testing Chapter 6

2 Chapter Goals Distinguish between following an algorithm and developing one Describe the pseudocode constructs used in expressing an algorithm Use pseudocode to express an algorithm Describe two approaches to testing Design and implement a test plan

Introduction to the chapter Chapter 6 is the first chapter in the programming layer. In Chapters 2 and 3, we covered the basic information necessary for understanding a computing system, including number systems and ways to represent different types of information in a computer. In Chapters 4 and 5, we covered the hardware components of a computer. Now the emphasis changes from what a computer system is to how to use one. 3

Machine Language The only programming instructions that a computer actually carries out are those written using machine language –The instructions built into the hardware of a particular computer. –Initially humans had no choice except to write programs in machine language because other programming languages had not yet been invented. 4

Machine Language Each machine- language instruction performs only one very low- level task. –Each small step in a process must be explicitly coded in machine language. –Even the small task of adding two numbers together must be broken down into smaller steps Enter a number into the accumulator, add a number to it, save the result. 5

Machine Language Recall the four steps in the fetch– execute cycle: –1. Fetch the next instruction ( from the place named in the program counter). –2. Decode the instruction ( and update the program counter). –3. Get data ( operand) if needed. –4. Execute the instruction. 6

Assembly language One step up from machine code Assembly language 7

High level programming languages Before we can write a program in a high level language, we must first express the algorithm in a language understood by programmers in many lanuages –Pseudo code Pseudo code is a language that allows us to express algorithms in a clearer form. 8

9 Pseudocode One of the popular representation of Algorithm Widely choosen because: – easy to read and write – allow the programmer to concentrate on the logic of the problem –Structured in English language

10 Pseudocode A mixture of English and formatting to make the steps in an algorithm explicit Algorithm to Convert base-10 number to other bases While (the quotient is not zero) Divide the decimal number by the new base Make the remainder the next digit to the left in the answer Replace the original decimal number with the quotient

11 Pseudocode Pseudocode – what is it? A mixture of English and formatting to make the steps in an algorithm explicit A way of expressing algorithms that uses a mixture of English phrases and indention to make the steps in the solution explicit There are no grammar rules in pseudocode Pseudocode is not case sensitive

12 Algorithms Algorithm – what is it? A set of unambiguous instructions for solving a problem or subproblem in a finite amount of time using a finite amount of data Why must instructions be unambiguous? Why must time and data be finite?

13 Following an Algorithm

14 Following an Algorithm Algorithm for preparing a Hollandaise sauce IF concerned about cholesterol Put butter substitute in a pot ELSE Put butter in a pot Turn on burner Put pot on the burner WHILE (NOT bubbling) Leave pot on the burner Put other ingredients in the blender Turn on blender WHILE (more in pot) Pour contents into lender in slow steam Turn off blender

15

PSEUDOCODE TUTORIAL 16

17 Developing an Algorithm Two methodologies used to develop computer solutions to a problem –Top-down design focuses on the tasks to be done –Object-oriented design focuses on the data involved in the solution But first, let's look at a way to express algorithms: pseudocode

18 Pseudocode A way of expressing algorithms that uses a mixture of English phrases and indention to make the steps in the solution explicit There are no grammar rules in pseudocode Pseudocode is not case sensitive

19 Following Pseudocode Converting base 10 to another base What is 93 in base 8? 93/8 gives 11 remainder 5 11/8 gives 1 remainder 3 1/ 8 gives 0 remainder 1 answer While (the quotient is not zero) Divide the decimal number by the new base Set the next digit to the left in the answer to the remainder Set the decimal number to the quotient What is 93 in base 8?

20 Following Pseudocode Easier way to organize solution

21 Pseudocode for Complete Computer Solution Write "Enter the new base" Read newBase Write "Enter the number to be converted" Read decimalNumber Set quotient to 1 WHILE (quotient is not zero) Set quotient to decimalNumber DIV newBase Set remainder to decimalNumber REM newBase Make the remainder the next digit to the left in the answer Set decimalNumber to quotient Write "The answer is " Write answer

22 Pseudocode Functionality Variables Names of places to store values quotient, decimalNumber, newBase Assignment Storing the value of an expression into a variable Set quotient to 64 quotient <-- 64 quotient <-- 6 *

23 Pseudocode Functionality Output Printing a value on an output device Write, Print Input Getting values from the outside word and storing them into variables Get, Read

24 Pseudocode Functionality Repetition Repeating a series of statements Set count to 1 WHILE ( count < 10) Write "Enter an integer number" Read aNumber Write "You entered " + aNumber Set count to count + 1

25 Pseudocode Functionality Selection Making a choice to execute or skip a statement (or group of statements) Read number IF (number < 0) Write number + " is less than zero." or Write "Enter a positive number." Read number IF(number < 0) Write number + " is less than zero." Write "You didn't follow instructions."

26 Pseudocode Functionality Selection Choose to execute one statement (or group of statements) or another statement (or group of statements) IF ( age < 12 ) Write "Pay children's rate" Write "You get a free box of popcorn" ELSE IF ( age < 65 ) Write "Pay regular rate" ELSE Write "Pay senior citizens rate"

27 Pseudocode Example Problem: Read in pairs of positive numbers and print each pair in order. WHILE (not done) Write "Enter two values separated by blanks" Read number1 Read number2 Print them in order

28 Pseudocode Example How do we know when to stop? Let the user tell us how many Print them in order? If first number is smaller print first, then second If first number if larger print second, then first

29 Pseudocode Example Write "How many pairs of values are to be entered?" Read numberOfPairs Set numberRead to 0 WHILE (numberRead < numberOfPairs) Write "Enter two values separated by a blank; press return" Read number1 Read number2 IF(number1 < number2) Print number1 + " " + number2 ELSE Print number2 + " " number1 Increment numberRead

30 Walk Through DataFill in values during each iteration 3numberReadnumber1number numberOfPairs What is the output?

31 Translating Pseudocode To What? High-level language

32 Testing Test plan A document that specifies how many times and with what data the program must be run in order to thoroughly test it Code coverage An approach that designs test cases by looking at the code Data coverage An approach that designs test cases by looking at the allowable data values

33 Testing Test plan implementation Using the test cases outlined in the test plan to verify that the program outputs the predicted results

Testing tutorials Why Testing is Important? Seven Testing Principles Software development life cycle and the software testing life cycleSoftware development life cycle and the software testing life cycle Unit testing Integration testing 34

Low-Level Programming Languages, Pseudo code and Testing Chapter 6