Week 2 - Algorithm & Flowchart PDF
Document Details
Uploaded by Deleted User
NU Dasmariñas
Tags
Related
Summary
This document covers the concepts of algorithms and flowcharts. It provides examples and explanations of both algorithms, which are step-by-step problem-solving procedures, and flowcharts, which visually represent these steps. The document also includes examples of different algorithm types, specifically those for mathematical conversions.
Full Transcript
Week 2 – Algorithm & Flowchart CCPRGG1L- Fundamentals of Programming At the end of the session, the students shall be able to: To understand the concept of Problem solving To understand steps involved in algorithm development Draw the symbols used in Flowcharts Let’s do Recap!!!! Al...
Week 2 – Algorithm & Flowchart CCPRGG1L- Fundamentals of Programming At the end of the session, the students shall be able to: To understand the concept of Problem solving To understand steps involved in algorithm development Draw the symbols used in Flowcharts Let’s do Recap!!!! Algorithm Step-by-step actions to solve a particular program. Expressed using natural verbal but somewhat technical annotations. Algorithm Properties No ambiguity in instructions. Specific instruction to task. Finite description. General to write a program. No program codes (as far as practicable). Algorithm Example Task: Write an algorithm to make a telephone call. Step 1: Remember or read the telephone number Step 2: Lift the receiver Step 3: Is there a dial tone? If yes, dial telephone and go to step 4. If no, put down the receiver. Go to step 2 Step 4: Speak Step 5: Put down the receiver. Pseudo code 'Pseudo' means imitation. 'code' refer to instruction written in the programming language. Generic way of describing an algorithm without using any specific programming language. CCPRGG1L Fundamentals of Programming Pseudo code properties Plain English texts. Emphasize on the design of computer program. Structured English. Detailed and readable to draw an inference. Enables programmers to concentrate on algorithm. Pseudo code Example Task: Print the highest number from 3 numbers. Flowcharts Provides the pictorial representation of the algorithm to solve a problem. CCPRGG1L Fundamentals of Programming Flowchart Symbols Flowchar t Example CCPRGG1L Fundamentals of Programming Always Remember Example No.1: Write an algorithms and flowchart that converts the input dollar to its peso exchange rate equivalent. Assume that the present exchange rate is 51.50 pesos against the dollar. 1. Input the value of dollar 2. Compute the value of pesos using the formula pesos = 51.50 * dollar 3. Display the value of pesos Start Input Dollar Compute pesos = 51.50 * dollar Display Pesos End Example No.2: Write an algorithm and flowchart program that converts an input inch(es) into its equivalent centimeters. Take note that one inch is equivalent to 2.54cms.. 1.Input the value of inch(es) 2. Compute the value of centimeter using the formula cm= 2.54*inch 3. Display the value of cm Check the number if odd or even Input a number Check the number if the number is visible by two , the number is even , if it is not the number is odd Display the number Input a Check the If False Start number number visible by 2 Odd True Even End Start Input inches Compute cm= 2.54*inch Display CM Start Example No.3: Write an algorithm and flowchart that converts a Temperature from Fahrenheit (℉) to Celsius (℃) C= 5/9 *(F-32) 1. Input the value of Fahrenheit 2. Calculate the temperature using the equation C= 5/9*(F- 32) Start Input Fahrenheit Calculate C=5/9*(F-32) Display Celsius End References Dale, Nell and Weems, Chip, Introduction to Pascal and Structured Design, 4th edition, D. C. Heath and Company, Lexington, Massachusetts, 1994. Java Objects and Classes. Retrieved from https://www.tutorialspoint.com/java/java_object_classes. htm Introduction to programming. Retrieved from https://ocw.mit.edu/courses/electrical-engineering-and-c omputer-science/6-092-introduction-to-programming-in-j ava-january-iap-2010/