The Hashemite University Computer Engineering Department

Slides:



Advertisements
Similar presentations
Chapter 1 - An Introduction to Computers and Problem Solving
Advertisements

Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
 Control structures  Algorithm & flowchart  If statements  While statements.
Introduction to C Programming
ITEC113 Algorithms and Programming Techniques
Chapter 2- Visual Basic Schneider
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Chapter 2: Input, Processing, and Output
Program design example Task: Develop an algorithm expressed in pseudocode for a specified problem specified problem.
Introduction to C Programming
Structured Program Development in C
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Pseudocode.
Chapter 3 Planning Your Solution
BPC.1 Basic Programming Concepts
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Chapter 1: Introduction To Computer | SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005 Slide 1 Introduction To Computers.
Chapter 1 Pseudocode & Flowcharts
Data Structures and Programming.  John Edgar2.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Sw development1 Software Development 1.Define the problem (Analysis) 2.Plan the solution 3.Code 4.Test and debug 5.Maintain and Document.
Structured COBOL Programming, Stern & Stern, 9th edition
CSC141 Introduction to Computer Programming
Spring 2005, Gülcihan Özdemir Dağ Lecture 3, Page 1 BIL104E: Introduction to Scientific and Engineering Computing, Spring Lecture 3 Outline 3.1 Introduction.
Introduction CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Programming Lifecycle
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Structural Program Development: If, If-Else Outline.
CSE 102 Introduction to Computer Engineering What is an Algorithm?
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
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.
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.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Chapter 2: General Problem Solving Concepts
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
The basics of the programming process The development of programming languages to improve software development Programming languages that the average user.
1 Program Planning and Design Important stages before actual program is written.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Program Development C# Programming January 30, 2007 Professor J. Sciame.
CS2301:Computer Programming 2
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
C++ Programming Lecture 14 Arrays – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
CMSC 2021 Software Development. CMSC 2022 Software Development Life Cycle Five phases: –Analysis –Design –Implementation –Testing –Maintenance.
CSCI 161 Lecture 3 Martin van Bommel. Operating System Program that acts as interface to other software and the underlying hardware Operating System Utilities.
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.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
 Problem Analysis  Coding  Debugging  Testing.
Algorithm & Programming
Chapter 2- Visual Basic Schneider
Lecture 2 Introduction to Programming
Unit# 9: Computer Program Development
Problem Solving Techniques
Structured Program
Programming Fundamentals (750113) Ch1. Problem Solving
1) C program development 2) Selection structure
Chapter 2- Visual Basic Schneider
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
Programming Fundamentals (750113) Ch1. Problem Solving
Software Development Process
Programming Fundamentals (750113) Ch1. Problem Solving
CHAPTER 6 Testing and Debugging.
Structural Program Development: If, If-Else
Presentation transcript:

The Hashemite University Computer Engineering Department C++ Programming Language Lecture 2 Problem Analysis and Solution Representation The Hashemite University Computer Engineering Department (Adapted from the textbook slides)

The Hashemite University Outline Program development cycle. Algorithms development and representation. Examples. The Hashemite University

Program Development Cycle Program development cycle steps: Problem definition. Problem analysis (understanding). Algorithm development: Ways for algorithm representation: Human language Pseudocode. Flowcharts (also called UML activity diagram). Coding. Execution and testing. Maintenance. Recall that such cycle and all the techniques presented in this lecture are the same for any programming language you want to use not only for C++. The Hashemite University

The Hashemite University Problem Definition To understand the problem is half the solution. Describe it by precise, up to the point statements that will make both analyzing and solving the problem easier and clearer. The Hashemite University

The Hashemite University Problem Analysis Determine the inputs, outputs, and the required operations. Explore all possible solutions. Pick the easiest, in terms of implementation cost (space, time) one. The Hashemite University

Algorithm Development Algorithm is a procedure that determines the: Actions to be executed. Order in which these actions are to be executed (which is called program control and in industry it is called work flow). So, it is a plan for solving the given problem. You must validate the developed algorithm, i.e. make sure that it solves the correct problem. You must verify the developed algorithm, i.e. make sure that it produces correct results. You must check the feasibility (in terms of the needed resources, ease of implementation, ease of understanding and debugging, its expected execution time, etc.) of the developed algorithm. The Hashemite University

Algorithm Representation – Human Language Use your own language to represent the steps of the developed algorithm. Example: adding two integers: 1. Prompt the user to enter two numbers. 2. Add them and store the result. 3. Display the sum to the user on the screen. The Hashemite University

Algorithm Representation – Pseudocode Artificial, informal language used to develop algorithms. Kind of structured English for describing algorithms. Middle approach between human language and C++ code. It is convenient and user friendly. Not actually executed on computers Allows us to “think out” a program before writing the code for it Usually easy to convert into a corresponding C++ program Consists only of executable statements, i.e. no definitions or declarations. The Hashemite University

Pseudocode Notations I Input: Input from keyboard: Get. Input from file or memory location: Read. Output: Output to printer: Print. Output to file: Write. Output to screen: Display, Prompt (usually followed by Get). Values assignment: Initial values: Initialize, Set. Results of computation: =, . Keeping variables for later use: Save, Store. The Hashemite University

Pseudocode Notations II Arithmetic computation: Either use exact operators (+, *, /, -) or equivalent words of them (add, multiply, divide, subtract). Computations: either use Compute or represent the actual operation mathematically. E.g. Compute average or avg = sum/count. Control structures: Use the actual words as it is: If, If – then – Else, While , do – While, For – to --, ... Relational operators: Write them as words: greater then, less than or equal, etc. Or you can use their symbols: >, <=, etc. The Hashemite University

The Hashemite University Pseudocode Examples Adding two numbers: 1. Prompt user for number1 2. Get number1 3. Prompt user for number2 4. Get number2 5. Add number1 and number2 6. Set sum to the result 7. Display sum Other examples (on board): Deciding the grade (A-F) of a student. The Hashemite University

Algorithm Representation – Flowcharts Represent the algorithms or computer programs execution steps graphically. The American National Standards Institute (ANSI) published a standard for flowcharts that includes a definition of their symbols (see next slide). Pseudocode is preferred over flowcharts since: More readable. Can be converted into C++ code easier. Flow charts are very similar to the UML (Unified Modeling Language) activity diagram with some differences in the used symbols. UML is an industry standard for modeling software systems. We will study flowcharts not activity diagrams in this course. The Hashemite University

The Hashemite University Flowcharts Symbols The Hashemite University

The Hashemite University Flowchart Examples Numbers addition example. The Hashemite University

The Hashemite University Example III Write a program that reads three numbers from a file. If the multiplication of these numbers is greater than or equal their sum then print “Winner” on the screen”, otherwise print “Loser” on the screen. Solution: On board. The Hashemite University

The Hashemite University Example I Symbol grading system: Deciding the grade (A-F) of a student. Solution: On board. The Hashemite University

The Hashemite University Example II Car Purchase System: Write a program that prompt the user to enter the money balance that is available with him and based on available cars models prices it will select the best car that the user can buy. The result will be printed on the screen. Solution: On board. The Hashemite University

The Hashemite University Coding Writing the source code of your solution that is to convert the developed algorithm into code statements of the used language, i.e. C++. Some useful tips: Make sure of using correct syntax. Use meaningful identifiers to make your code more readable. Add suitable documentation and comments. Make your code modular or structured as possible. The Hashemite University

The Hashemite University Execution and Testing Compilation and debugging. Types of errors: Syntax errors (Compile time errors): Errors caught by compiler Logical errors (Runtime errors): Errors which have their effect at execution time Non-fatal logic errors program runs, but has incorrect output Fatal logic errors program exits prematurely Tracing to verify your program with different sets of inputs. The Hashemite University

The Hashemite University Maintenance Not always applicable in education, i.e. highly required in real world jobs. Update your code based on: Discovered and reported bugs. Customer feedback to make your application more efficient and flexible. Upgrade the code. The Hashemite University

The Hashemite University Additional Notes This lecture covers the following material from the textbook: Fourth edition: Chapter 2: Sections 2.1 - 2.3 The Hashemite University