Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.

Slides:



Advertisements
Similar presentations
CS101: Introduction to Computer programming
Advertisements

1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Chapter 2: Problem Solving
Chapter 2: Problem Solving
Chapter 1 - An Introduction to Computers and Problem Solving
ITEC113 Algorithms and Programming Techniques
Chapter 2: Algorithm Discovery and Design
Programming Fundamentals (750113) Ch1. Problem Solving
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
PRE-PROGRAMMING PHASE
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Fundamentals of C programming
1 L07SoftwareDevelopmentMethod.pptCMSC 104, Version 8/06 Software Development Method Topics l Software Development Life Cycle Reading l Section 1.4 – 1.5.
Chapter 2: Problem Solving
CSEB114: PRINCIPLE OF PROGRAMMING Chapter 2: Problem Solving.
Chapter 2: Problem Solving
U NDERSTANDING P ROBLEMS AND HOW TO S OLVE THEM BY USING C OMPUTERS.
Simple Program Design Third Edition A Step-by-Step Approach
หลักการโปรแกรม เพื่อแก้ปัญหาโดยใช้คอมพิวเตอร์
Programming Lifecycle
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Software Life Cycle What Requirements Gathering, Problem definition
Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation.
Chapter 2 Problem Solving On A Computer 2.1 Problem Solving Steps Solving a problem on a computer requires steps similar to those followed when solving.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
CMSC 1041 Algorithms II Software Development Life-Cycle.
Controlling Execution Programming Right from the Start with Visual Basic.NET 1/e 8.
กระบวนการแก้ปัญหาด้วย คอมพิวเตอร์ 3 พฤษภาคม :00-17:00.
CMSC 104: Peter Olsen, Fall 99Lecture 9:1 Algorithms III Representing Algorithms with pseudo-code.
Principles of Programming - NI July Chapter 2: Problem Solving In this chapter you will learn about: Introduction to Problem Solving Software development.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
1 Program Planning and Design Important stages before actual program is written.
 In this chapter you will learn about:  Introduction to Problem Solving  Software development method (SDM)  Specification of needs  Problem analysis.
CSEB114: Principle of programming
The Hashemite University Computer Engineering Department
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
Controlling Program Flow with Decision Structures.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Programming Fundamentals Introduction to Problem Solving  Programming is a problem solving activity. When you write a program, you are actually writing.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
Program Program is a collection of instructions that will perform some task.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
Pseudocode. Algorithm A procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
 Problem Analysis  Coding  Debugging  Testing.
SOFTWARE DEVELOPMENT METHOD
Chapter 2- Visual Basic Schneider
ALGORITHMS AND FLOWCHARTS
Algorithms and Flowcharts
Lecture 2 Introduction to Programming
Programming Fundamentals
Algorithm and Ambiguity
Unit# 9: Computer Program Development
Problem Solving Techniques
Structured Program
1) C program development 2) Selection structure
Chapter 2- Visual Basic Schneider
Introduction to Algorithms and Programming
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
Algorithm and Ambiguity
Understanding Problems and how to Solve them by using Computers
Click to add Text Computers & Instructions. Computers are given instructions in the form of computer programs that are created through the development.
ICT Gaming Lesson 2.
Basic Concepts of Algorithm
Presentation transcript:

Problem Solving Techniques

Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language and generate the instructions from the computer from that code. n The program description is called source code or C code. n Compiled program is called object code or machine code

Problem solving n Is the process of transforming the description of a problem into the solution of the problem by using our knowledge of the problem domain and relying on our ability to select and use appropriate problem-solving strategies, techniques, and tools.

Method for Problem Solving n Requirement Specification n Analysis n Design n Implementation n Testing and Verification n Documentation Also known as Software development methods or Software Life Cycle

Requirement Specification –Eliminated ambiguities in the problem statement –understanding exactly what the problem is –what needed to solve it –what are the solution should provide –any constraint or special conditions n how precisely you define the problem is depend on degree of familiarity on the problem.

Analysis n identified problem inputs, outputs and collected information about the inputs n Formulas or equations to be used. n If you can acquired a clear understanding of the problem and have a precise requirements specification usually will make analysis phase easy

Design n developed a series of steps with a logical order which, when applied would produce the output of the problem n using algorithms represented as flowchart or pseudocode

Implementation n Implementation of the algorithm in a programming language. n Translate algorithm into a statement of programming language n a computer program is a sequence of a finite number of statements expressed in a programming language in a specific logical order that, when executed, produce the solution for a problem

Implementation - programming errors n There are three types of programming errors –design, syntax and run-time error n design errors occur during the analysis, design, and implementation phases –incorrect method, mistakes on translating algorithm & design erroneous data –difficult to detect

Syntax errors n Are violations of syntax rules, which define how the elements of a programming language must be written –occur during implementation phase –detected by compiler –error message display

Run-time errors n Are detected by the computer while your program is being executed. n Cause by instruction that require the computer to do something illegal such as attempting to store inappropriate data or divide a number by zero

What is a program ? n Is a set of instructions for a computer n receive data, carry out the instructions, and produce useful results

Algorithms n A clear and precise procedure for solving a given problem, and although the word algorithm evolved from the name of 8th century Arabian mathematician, the idea pre-dates him by over a millennia. In order to solve a problem on a computer, the corresponding algorithm must exist as a series of well-defined steps. A lot of research in computer science is involved with finding algorithms which : –solve new problems, –solve old problems more efficiently, or –produce approximate solutions to problems for which no known algorithm exists.

Algorithm Design n 4 steps must be carried out –understand the problem –get an idea of how an algorithmic procedure might solve the problem –formulate the algorithm and represent it as a program –evaluate the program for accuracy and for its potential as a tool for solving other problems.

Pseudocoding n Is a semiformal, English-like language with a limited vocabulary that can be used to design and describe algorithms n can be used for –designing algorithms –communicating algorithms as programs –implementing algorithms as programs –debugging logic errors in program –documenting programs for future maintenance and expansion purposes

Pseudocode n Have limited vocabulary n be easy to learn n produce simple, English -like narrative notation n be capable of describing all algorithms, regardless of their complexity

Coventions For Pseudocoding n Should includes keywords that describe operations and some appropriate, English-like descriptions of operands n each pseudocode should be written on a separate line. If a statement requires more than one line, the continuation lines should be indented n the statement that make up a sequence control should be start with compute, set or initialize n statements in a sequence structure can be grouped into a block by enclosing them between the keywords begin and end. Such statement should be indented. n Terminate each if statement with the keyword end_if

Coventions For Pseudocoding n For the repetition control structure, use the while statement and indent the loop-body. Terminate each while statement with the keyword end_while n All words in pseudocode statement must be as easy as possible for nonprogrammers to understand

Flowchart n Flowchart is simply a graphical method for representing the program’s flow, and is language independent; n Each box in a flowchart represents a particular type of instruction, action or data store, and arrows are drawn between the boxes to show hoe the program flow occurs between statements. Sometimes the arrows are labeled with text to show whether a decision was true or false.

Basic Control & Looping Concepts n If …then…else n while end n do ….while n for...next n loop …until

Examples of Problem Solving

Obtain 2 numbers from Keyboard, compute the sun of the numbers and display the results n Input the first number n Input the second number n Add the two numbers n Output the sum

Obtain two numbers from the keyboard, and determine and display which (if either) is the larger of the two numbers Input the first number from the keyboard Input the second number from the keyboard If the first number is greater than the second number print it Else if the second number is greater than the first number print it Else print a message starting that the numbers are equal End If

Obtain a series of +ve number from the keyboard, and determine and display the sum of the numbers. Assume that the user types the sentinel value -1 to indicate “end of data entry” do Input a value from the keyboard while value is < 0 and value not = -1 While the input value is not equal to -1 add the number to the running total do input the next number while value < 0 and not equal = -1 End While Print the sum

More examples…will continue on next lecture