Outline. Program development cycle. Algorithms development and representation. Examples.

Similar documents
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

CS110D: PROGRAMMING LANGUAGE I

Chapter 3 Structured Program Development

Structured Program Development in C

Computer System and programming in C

Programming Languages and Program Development Life Cycle Fall Introduction to Information and Communication Technologies CSD 102

Chapter 2 - Problem Solving

Introduction to C Programming

Chapter 8 Algorithms 1

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

III. Check if the divisors add up to the number. Now we may consider each of these tasks separately, assuming the others will be taken care of

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #13. Loops: Do - While

CS 199 Computer Programming. Spring 2018 Lecture 2 Problem Solving

8 Algorithms 8.1. Foundations of Computer Science Cengage Learning

int n = 10; int sum = 10; while (n > 1) { sum = sum + n; n--; } cout << "The sum of the integers 1 to 10 is " << sum << endl;

CSc 10200! Introduction to Computing. Lecture 1 Edgardo Molina Fall 2013 City College of New York

1. Introduction to Programming

Introduction to Programming

Chapter 1 - An Introduction to Computers and Problem Solving

Python - Week 1. Mohammad Shokoohi-Yekta

Dr. Iyad Jafar. Adapted from the publisher slides

Lecture 01 & 02 Computer Programming

BIL101E: Introduction to Computers and Information systems Lecture 8

C H A P T E R 1. Introduction to Computers and Programming

Fundamentals of Programming (Python) Getting Started with Programming

Introduction to C++ Programming. Adhi Harmoko S, M.Komp

Repetition Structures

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1

SNS COLLEGE OF ENGINEERING,

Chapter Twelve. Systems Design and Development

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

Computer Fundamentals

Computers and FORTRAN Language Fortran 95/2003. Dr. Isaac Gang Tuesday March 1, 2011 Lecture 3 notes. Topics:

Add Subtract Multiply Divide

S/W Programming & Languages

Chapter 1 Lab Algorithms, Errors, and Testing

4. The is a diagram that graphically depicts the steps that take place in a program. a. Program b. Flowchart c. Algorithm d. Code e.

Fundamental of Programming (C)

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Stepwise Refinement. Lecture 12 COP 3014 Spring February 2, 2017

Fundamentals of Programming. Lecture 6: Structured Development (part one)

Algorithms. Chapter 8. Objectives After studying this chapter, students should be able to:

Fundamentals of Programming

Higher Computing Science Software Design and Development - Programming Summary Notes

Individual research task. You should all have completed the research task set last week. Please make sure you hand it in today.

Chapter 4 Introduction to Control Statements

Constructing Algorithms and Pseudocoding This document was originally developed by Professor John P. Russo

COP 1220 Introduction to Programming in C++ Course Justification

EKT 120/4 Computer Programming KOLEJ UNIVERSITI KEJURUTERAAN UTARA MALAYSIA

CENTRAL TEXAS COLLEGE COSC 1315 INTRODUCTION TO COMPUTER PROGRAMMING. Semester Hours Credit: 3 INSTRUCTOR: OFFICE HOURS:

C++ Programming Language Lecture 1 Introduction

Chapter 1 INTRODUCTION TO COMPUTER AND PROGRAMMING

Introduction to Computer Science Midterm 3 Fall, Points

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved.

The births of the generations are as follow. First generation, 1945 machine language Second generation, mid 1950s assembly language.

Unit II. (i) Computer Programming Languages

Pseudo Code and Flow Charts. Chapter 1 Lesson 2

CHAPTER 2.1 CONTROL STRUCTURES (SELECTION) Dr. Shady Yehia Elmashad

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/

FLOW CHART AND PSEUDO CODE

More C Pointer Dangers

Introduction to C++ Programming Pearson Education, Inc. All rights reserved.

CS112 Lecture: Repetition Statements

How to approach a computational problem

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

Computing and compilers

Chapter 6 Programming the LC-3

Copyright 2005 Department of Computer & Information Science

LECTURE 5 Control Structures Part 2

Chapter Two: Program Design Process and Logic

Arithmetic Operators. Binary Arithmetic Operators. Arithmetic Operators. A Closer Look at the / Operator. A Closer Look at the % Operator

Repetition Algorithms

Engineering Computing M1H Together Towards A Green Environment

INFS 214: Introduction to Computing

Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs

LESSON 13 OVERVIEW OF PROGRAM DEVELOPMENT PHASES

LECTURE 0: Introduction and Background

Working with JavaScript

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 1

Pseudocode syntax, descriptions and examples

بسم اهلل الرمحن الرحيم

STUDENT OUTLINE. Lesson 8: Structured Programming, Control Structures, if-else Statements, Pseudocode

Chapter 1 Program Design

CSE101-lec#12. Designing Structured Programs Introduction to Functions. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU

CSC 121 Spring 2017 Howard Rosenthal

Programming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs

PROBLEM SOLVING AND PYTHON PROGRAMMING

PROBLEM SOLVING TECHNIQUES

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #16 Loops: Matrix Using Nested for Loop

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. A Guide to this Instructor s Manual:

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Programming for Engineers Iteration

SNS COLLEGE OF ENGINEERING

Syllabus of Diploma Engineering. Computer Engineering. Semester: II. Subject Name: Computer Programming. Subject Code: 09CE1104

IS 0020 Program Design and Software Tools

Fundamentals of Computing and Digital Literacy. Sample. Assignment title: Develop a Wiki. Marking Scheme

CS111: PROGRAMMING LANGUAGE1. Lecture 2: Algorithmic Problem Solving

CS 142 Style Guide Grading and Details

Transcription:

Outline Program development cycle. Algorithms development and representation. Examples. 1

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++. 2

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. 3

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. 4

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. 5

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. 6

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. 7

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 8

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. 9

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. 10

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

Flowcharts Symbols The Hashemite University 12

Flowchart Examples Numbers addition example. Start Get number1 Get number2 sum = number1 + number2 Display sum End 13

Decision flow chart 14

Looping flow chart 15

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. 16

Class Average Algorithm Problem: Calculate and report the gradepoint average for a class Discussion: The average grade equals the sum of all grades divided by the number of students Output: Average grade Input: Student grades Processing: Find the sum of the grades; count the number of students; calculate average 17

Flowchart 18

Pseudocode Program: Determine the average grade of a class Initialize Counter and Sum to 0 Do While there are more grades Get the next Grade Add the Grade to the Sum Add 1 to the Counter Loop Compute Average = Sum/Counter Display Average 19

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. 20

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. 21

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. 22