Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to programming

Similar presentations


Presentation on theme: "Introduction to programming"— Presentation transcript:

1 Introduction to programming
Algorithms: introduction to flowchart

2 Agenda Things to remember. Problem solving process. Algorithms
Flowchart and Psudocode Flowchart symbols. Main structures of flowcharts Examples Exercises

3 Things to remember: Computer is one of the tools that has been used to solve problems in different fields applying the latest technology. Computer solves problems using different programming languages to design and produce suitable solutions(codes).

4 Problem solving process:
Recognize and understand the problem. Accumulate facts. Select appropriate theory. Make necessary assumptions. Solve the problem. Verify results.

5 In another way:

6 Steps of program development:
Develop an Algorithm and a Flowchart. Write the program in a computer language.(e.g. Java, C#,-----) Enter the program into the computer. Test and debug the program. Run the program, input data, and get the results from the computer.

7 Algorithms: Definition: “An Algorithm is just a detailed sequence of simple steps that are needed to solve a problem”. Represent algorithms: Using Flowchart and Pseudocode.

8 Definitions: Pseudocode:
Specifies the steps of algorithm using essentially natural language of super imposed control structure. Flowchart: a traditional graphical tool with standardized symbols. Show the sequence of steps in an algorithm. OR “Is a graphical representation of an algorithm”.

9 Example : Pseudocode Flowchart BEGIN fill a kettle with water
boil the water in the kettle put the tea leaves in the pot pour boiling water in the pot END

10 Flowchart symbols: External sheet will be uploaded with the lecture .
Connectors : same page and on another page. Page 1 Page 2

11 The main structures in flowchart:
1.Sequence:In a computer program or an algorithm, sequence involves simple steps which are to be executed one after the other. The steps are executed in the same order in which they are written In a flowchart, sequence is expressed as: In pseudocode, sequence is expressed as: process 1 process 2 process n

12 2. Selection: (binary and multi)
Is used in computer programs or algorithms to determine which particular step or set of steps to be executed. Binary selection Multi- way selection No Yes

13 3. Repetition: Allows for a portion of an algorithm or computer program to be done any number of times dependent on some condition being met. An occurrence of repetition is usually known as a loop. Each loop has a termination condition to stop the repetition, or the obvious outcome is that the loop never completes execution (an infinite loop). The termination condition can be checked or tested: at the beginning and is known as a pre-test loop or at the end of the loop and is known as a post-test loop.

14 Structure of pre-test repetition:
In pseudocode, pre-test repetition is expressed as: WHILE condition is true process(es) ENDWHILE Repetition In flowcharting pre-test repetition is expressed as:

15 Example: Pre-test Repetition Pseudocode WHILE the train is moving
keep wholly within the carriage ENDWHILE Pre-test Repetition Flowchart

16 Structure of post-test repetition:
In pseudocode, post-test repetition is expressed as: REPEAT process UNTIL condition is true Repetition In a flowchart post-test repetition is expressed as:

17 Example: Pseudocode REPEAT UNTIL fluffy beat the egg whites
Post-test Repetition Pseudocode REPEAT beat the egg whites UNTIL fluffy Post-test Repetition Flowchart

18 What is the output of the following flowchart when the input Num= 10
Example: What is the output of the following flowchart when the input Num= 10 Input: Num <- 10 Enter a Number >> 10 Category A Num = 10 10 > 0 ? => YES Output: “Category A”

19 What is the output of the following flowchart when the input is Num= 0
Example: What is the output of the following flowchart when the input is Num= 0 Input: Num <- 0 Enter a Number >> 0 Category B Category A Num = 0 0 > 0 ? => NO Output: “Category B” Output: “Category A”

20 Assignment Will be posted at my academic website under CPIT202 and all the instructions will be clarified Deadline will be next Saturday 15th September by 2:00 PM maximum Printed copy of your assignment should be handed to me with full details of the student(Name-ID- -class-Hand Over date) Please follow the instructions.


Download ppt "Introduction to programming"

Similar presentations


Ads by Google