INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.

Slides:



Advertisements
Similar presentations
Programming Logic and Design Fourth Edition, Introductory
Advertisements

Introduction to C Programming
ITEC113 Algorithms and Programming Techniques
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 2, Lecture 2.
Program Design and Development
Chapter 2: Introduction to C++.
Introduction to C Programming
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 02.
Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - Welcome Application: Introduction to C++
CH Programming An introduction to programming concepts.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Introduction to Computational Linguistics Programming I.
Chapter 2 Overview of C Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
PROGRAMMING. Objectives Define the term program List and explain the steps involved in developing a program.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Input, Output, and Processing
Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...
Introduction to Computers (L02) * Hardware * Software * Programming Languages * Three Phase of Program Development * Development and Design Steps * Algorithms.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
Introduction to Programming with RAPTOR
Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)
Introduction to Pascal The Basics of Program writing.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Flowcharts and Algorithms. Review of Terms  A computer is a machine that can represent and manipulate data –Ultimately the data and the instructions.
ITEC113 Algorithms and Programming Techniques
Programming, an introduction to Pascal
1 Program Planning and Design Important stages before actual program is written.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
The Hashemite University Computer Engineering Department
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 3: Input/Output Samples.
Starter What does the following code do?
Programming what is C++
Topics Designing a Program Input, Processing, and Output
Chapter 6 JavaScript: Introduction to Scripting
Chapter 2 Introduction to C++ Programming
Completing the Problem-Solving Process
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
GC211Data Structure Lecture2 Sara Alhajjam.
Variables, Expressions, and IO
Programming Problem steps must be able to be fully & unambiguously described Problem types; Can be clearly described Cannot be clearly described (e.g.
Functions CIS 40 – Introduction to Programming in Python
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 2 Applications and Data.
Introduction to C++ Programming
Programming Funamental slides
CS111 Computer Programming
1) C program development 2) Selection structure
T. Jumana Abu Shmais – AOU - Riyadh
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
LOOPS The loop is the control structure we use to specify that a statement or group of statements is to be repeatedly executed. Java provides three kinds.
Presentation transcript:

INTRODUCTION TO ALGORITHMS PROGRAMMING

Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm structure. Understand the commands used to permit input, output and processing of data in pseudocode. Write out a complete pseudocode algorithm using sequential structures List the Do’s and Don’ts of writing pseudocode

What is an Algorithm? An algorithm is a sequence of precise instructions for solving a problem.

Pseudocode Algorithm Properties A pseudocode algorithm must have the following properties: It must be: Precise Unambiguous Logically sequenced Give correct solutions in all cases Eventually end.

Pseudocode Algorithm Structure Every pseudocode algorithm should have the following sections in the stated order Header: Algorithm’s name or title Declaration: A brief description of algorithm and variables used. i.e. a statement of the purpose, as well as stating variables. Body: Sequence of steps Terminator: An end statement

Algorithm Student data {Header} {This algorithm displays a student’s name and age on the screen.} Name string{Declaration} Ageinteger Start Display “Enter your name’ Accept Name Display “Enter your age:” {Body} Accept Age Display “Hello”, Name Display “You are”, Age, “years old” Stop{Terminator}

Pseudocode Algorithm Header The algorithm header is usually followed by comments. Comments can be used to remind you of what is taking place. They can be used to explain or clarify any part of an algorithm. A comment or lack of comment has no effect on the logic of the algorithm. It is solely for documentation purposes. Comments are written by enclosing them in braces. A Comment extends from the left brace to the right brace, and may span one or more lines.

Declaring the Variables The next step is to declare the variables. All variables must be declared before they can be used in the algorithm. The variables are followed by the data type of the variable. Variable declarations must appear after the program heading and a comment about what the program does, but before the word start of the main routine.

Body of the Pseudocode Algorithm The main executable code for the algorithm is in the body usually referred to as the main routine or simply main. The body consists of the main routine. The body consists of the part between Start and Stop. All algorithms end with a period. When we run a program it starts executing with the first statement in the main and ends when it reaches the last statement. The Body of the algorithm is also comprised of various structures. A structure can be sequence, a selection or a loop.

Body of the Pseudocode Algorithm The main routine of an algorithm or main body of an algorithm consists of, prompt, input, processing and output statements that make up the various structures.

Prompt When developing and algorithm prompts must be made. Prompts are messages that appear on the screen notifying the user of what data has to be entered. A prompt is needed for each input statement. Prompt statements begin with the command PRINT followed by the string enclosed in quotes. –E.G. Print ‘Enter two numbers ’

Input Each prompt is followed by a read. The command that allows the input of data is the word Read followed by one or more variables, used to represent the data being entered and stored. When more than one variable is used a comma is placed between each variable. –Read num1, num2,num3

PRINTING INFORMATION OR OUTPUT Output can be sent to the screen when developing an algorithm for solving a problem. The command used is the word Print. Print can be used to output the value of a variable or to output a constant. –Print ‘Total Revenue is ‘ TotalRevenue

PROCESSING INVOLVING CALCULATIONS Calculations can be done by using the mathematical operations for addition, subtraction, multiplication or division. The results of a calculation must be stored in a variable for use. The result of the calculation is stored in the variable to the left of the

PROCESSING INVOLVING CALCULATIONS This variable is assigned the results of the calculation. Any statement, that assigns a value to a variable, is called and assignment statement. The value being assigned could be a constant a variable a calculation or expression.

Pseudocode Writing Do’s And Don’ts Do’s Use the assignment symbol in assignment statements not the equal sign. Use meaningful variable names Use indentation to show logic and scope Insert Comments to clarify meaning of blocks of code.

Pseudocode Writing Do’s And Don’ts Don’ts Do not use language specific statements in pseudocode e.g. writeln, readln Do not attempt to write Pascal code before writing the algorithm.

Template Provided By 500,000 Downloadable PowerPoint Templates, Animated Clip Art, Backgrounds and Videos