Chapter 1 Pseudocode & Flowcharts

Slides:



Advertisements
Similar presentations
Exercise (1).
Advertisements

Flow Charts, Loop Structures
UNIT 2. Introduction to Computer Programming
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 1 Pseudocode & Flowcharts
Fundamentals of Algorithms MCS - 2 Lecture # 4
Chapter 2- Visual Basic Schneider
Developing logic (Examples on algorithm and flowchart)
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 3 Planning Your Solution
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Algorithm & Flowchart.
Chapter 1 Pseudocode & Flowcharts
Computer Programming-1 CSC 111 Chapter 1 : Introduction.
CSC141 Introduction to Computer Programming
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
© 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
Flowcharts.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
Flowcharts and Algorithms. Review of Terms  A computer is a machine that can represent and manipulate data –Ultimately the data and the instructions.
Chapter 2: General Problem Solving Concepts
CHAPTER#3 PART1 STRUCTURED PROGRAM DEVELOPMENT IN C++ 2 nd semester King Saud University College of Applied studies and Community Service Csc.
CHAPTER#3 PART1 STRUCTURED PROGRAM DEVELOPMENT IN C++ 2 nd semester King Saud University College of Applied studies and Community Service Csc.
Structured Program Development Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CHAPTER 1 INTRODUCTION 1 st semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Basic problem solving CSC 111.
1 Program Planning and Design Important stages before actual program is written.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Chapter#3 Part1 Structured Program Development in C++
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
CSC 111. Solving Problems with Computers Java Programming: From Problem Analysis to Program Design, Third Edition3 Solving Problems Stages 1.Problem.
LESSON 1 Introduction to Programming Language. Computer  Comprised of various devices that are referred to as HARDWARE.  The computer programs that.
Concepts of Algorithms CSC-244 Unit Zero Pseudo code, Flowchart and Algorithm Master Prince Computer College Qassim University K.S.A.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Introduction to Flowcharts
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
Problem Solving Flowcharts. Flowcharts Introduction  Flowcharts allow us to create a visual representation of a solution to a problem DRAW  With flowcharts,
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Chapter 1 Introduction 2nd Semester H
Chapter One Problem Solving
Program design Program Design Process has 2 phases:
Unit 3: ALGORITHMS AND FLOWCHARTS
Chapter One Problem Solving
Chapter 2- Visual Basic Schneider
Computer Programming Flowchart.
Introduction To Flowcharting
ALGORITHMS AND FLOWCHARTS
Chapter 1 Pseudocode & Flowcharts
ALGORITHMS AND FLOWCHARTS
PROBLEM SOLVING CSC 111.
Pseudocode & Flowcharts
Structured Program
ALGORITHMS AND FLOWCHARTS
Chapter 2- Visual Basic Schneider
Algorithms & Pseudocode & Flowcharts
Chapter 1 Pseudocode & Flowcharts
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
WJEC GCSE Computer Science
Chapter 1 Pseudocode & Flowcharts
Algorithms & Pseudocode & Flowcharts
Introduction to Programming
Presentation transcript:

Chapter 1 Pseudocode & Flowcharts King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Noor Alhareqi & Alaa Altheneyan Chapter 1 Pseudocode & Flowcharts 1st Semester 1433-1434 H

Levels of Program Development Define the problem. Human thought Plan the problem solution.  writing the algorithm [pseudo-natural language (English, Arabic) or drawing the flowchart diagram). Code the program.  High Level Programming Language (C, C++, Java, …) Compile the program.  Machine Code Run the program. Test and debug the program. Asma Alosaimi

From Lec1 we learn that When planning for a problem solution, algorithms are used to outline the solution steps using English like statements, called pseudocode. or A flowchart , which is a graphical representation of an algorithm. Asma Alosaimi

Pseudocode Pseudocode is a detailed description of what a computer program must do, expressed in an English like language rather than in a programming language. Asma Alosaimi

Pseudocode Example Write a Program to Print the Sum of two integer Numbers Start the program Read the first number and save in the variable ( N1 ) Read the second number and save in the variable ( N2 ) Sum the both numbers and save the result in the variable ( Sum )  Sum = N1 + N2 Print the variable ( Sum ) End the program Asma Alosaimi

Flowchart A flowchart is a type of diagram that represents an algorithm , showing the steps as boxes of various kinds [ex: rectangles, diamonds, ovals], and their order by connecting these with arrows.  Asma Alosaimi

Flowcharts Symbols Start/End Start End Read/Print Print n1 Read n1 Arithmetic Operations N2 = n1+3 N2 = 5 Decision , can be used with loops n1 > 3

Solution start Draw a flowchart for a program that calculates and print the area and the perimeter of a rectangle. Input Length width Processing Area = length*width Perimeter = 2*( length + width) Output Area Perimeter Read L, W area = L * W perimeter = 2 (L+W) Print area Print perimeter End Asma Alosaimi

Total_Sal = Salary +Overtime Example 2 Draw the flow chart for a program that calculates the total salary for an employee using this equation: Total_Sal = Salary +Overtime Asma Alosaimi

Solution start Input Salary Overtime Processing Read Salary Total_Sal = Salary +Overtime Output Total_Sal Read Salary Read Overtime Total_Sal = Salary +Overtime Print Total_Sal End Asma Alosaimi

Example 3 Draw a flowchart for a program that calculates and prints the sum of the even integers from 2 to 30. Input No input. Processing Sum = 2+4+6+8+……+28+30. Output sum Asma Alosaimi

Solution Pesudocode: Start the program Create a variable to hold a counter from 2 to 30. Initialize the counter to 2. Create a variable to hold the sum. Initialize the sum to zero. Loop While the counter is less-than-or-equal to 30 add the counter to the sum add two to the counter. repeat until the counter reach 30 Print the sum. End of program Asma Alosaimi

Solution no Start Counter=2, Sum=0 yes Counter≤30 yes End Counter=2, Sum=0 Counter≤30 Sum= Sum + Counter Counter=Counter+2 Print Sum yes no yes Asma Alosaimi

Example 4 Draw a flowchart for a program that determine if the temperature degree is above or below freezing. Input Temp. Processing Check if Temp is below the 32  below freezing. Check if Temp is above the 32  above freezing. Output Print “below freezing” or “above freezing” Asma Alosaimi

Solution Asma Alosaimi

Example 5 Draw a flowchart for a program that accepts a person’s initial bank balance followed by a sequence of numbers representing transactions. A positive number represents a credit entry in the account and a negative number represents a debit entry. The input is terminated by a zero entry. The program should print the new balance. Asma Alosaimi

Solution Input bank balance. transactions Processing balance = balance + transaction. Output balance Asma Alosaimi

balance =balance + transaction Solution Start Read balance Read transaction balance =balance + transaction Transaction !=0 yes no Print balance End Asma Alosaimi

Example 6 Draw a flowchart for a program that calculates the Zakat, where the user enter the amount of money then the program show the zakat. Zakat =(2.5/100) * amount. Zakat is not calculated if the amount is less than 1000 S.R Asma Alosaimi

Solution Input amount. Processing Check if amount is below 1000  Zakat =0. Check if amount is above 1000 Zakat =(2.5/100) * amount Output Zakat Asma Alosaimi

Solution no Start Read amount yes Amount > 1000 Zakat =0. Zakat =(2.5/100)*amount Print Zakat Asma Alosaimi End