PSEUDOCODE & FLOW CHART

11
PSEUDOCODE & FLOW CHART

description

PSEUDOCODE & FLOW CHART. HOW TO PLAN YOUR PROGRAM. PROGRAM CAN BE REPRESENT USING : PSEUDOCODE FLOW CHART NS (NASSI SCHIDERMAN) CHART. 1. PSEUDOCODE. What is THAT ?? #$%$**$%#%#@. - PowerPoint PPT Presentation

Transcript of PSEUDOCODE & FLOW CHART

Page 1: PSEUDOCODE   &  FLOW CHART

PSEUDOCODE &

FLOW CHART

Page 2: PSEUDOCODE   &  FLOW CHART

HOW TO PLAN YOUR PROGRAM

PROGRAM CAN BE REPRESENT USING :

•PSEUDOCODE

•FLOW CHART

•NS (NASSI SCHIDERMAN) CHART

Page 3: PSEUDOCODE   &  FLOW CHART

1. PSEUDOCODEWhat is THAT ?? #$%$**$%#%#@

•Pseudocode consists of short, English phrases used to explain specific tasks within a program's algorithm (The algorithm is a set of precise instructions specifying how to carry out a specific task.

•Pseudocode should not include keywords in any specific computer languages. It should be written as a list of consecutive phrases.

•You should not use flowcharting symbols but you can draw arrows to show looping processes.

•Indentation can be used to show the logic in pseudocode as well.

•One programmer should be able to take another programmer's pseudocode and generate a program based on that pseudocode.

Page 4: PSEUDOCODE   &  FLOW CHART

Why PSEUDOCODE is necessary?

The programming process is a complicated one. You must first understand the program specifications, then organize your thoughts and create the program.

You must break the main tasks that must be accomplished into smaller ones in order to be able to eventually write fully developed code. Writing pseudocode WILL save you time later during the construction & testing phase of a program's development.

Page 5: PSEUDOCODE   &  FLOW CHART

How to write PSEUDOCODE?

• Make a list of the main tasks that must be accomplished on a piece of scratch paper.

• Then, focus on each of those tasks, try to break each main task down into very small tasks that can each be explained with a short phrase. There may eventually be a one-to-one correlation between the lines of pseudocode and the lines of the code that you write after you have finished pseudocoding.

Page 6: PSEUDOCODE   &  FLOW CHART

2. FLOW CHARTBegin/End

Display[ printf]

Data[ scanf ]

Decision[if, if .. else]

Process[ assignment statement or

any other statement]

Predefined process[ function]

Connector

Off page connector

Flow

Page 7: PSEUDOCODE   &  FLOW CHART

Example 1 –Program Specifications

Write a program that obtains two integer numbers from the user. It will print out the sum of those numbers.

Page 8: PSEUDOCODE   &  FLOW CHART

PSEUDOCODE

Prompt the user to enter the first integerObtain user's first integer inputPrompt the user to enter a second integerObtain user's second integer input

Add first integer and second integerStore the result in another variable

Display an output prompt that explains the answer as the sumDisplay the result

Page 9: PSEUDOCODE   &  FLOW CHART

FLOW CHART

Start

End

Prompt user “Enter first integer”

Prompt user “Enter second integer”

Display result of addition two integer numbers

Read first integer

Read second integer

Result = First Integer + Second Integer

Page 10: PSEUDOCODE   &  FLOW CHART

Example 2 // example of if statements#include <stdio.h>void main(){

int guess_input; 

printf( “Please enter a whole number\n”);scanf("%d",&guess_input);if (guess_input==1){printf( “Right number !\n”);printf( "Well Done.\n” );}

}

Page 11: PSEUDOCODE   &  FLOW CHART

FLOW CHART Start

Read a number

If number is 1

End

Prompt user “Enter any number”

Prompt user “Right number ! Well done!”

TRUE

FALSE