120 likes | 287 Views
CS 101 INTRODUCTION TO COMPUTER SCIENCES. DEPARTMENT OF COMPUTER SCIENCES. Pseudocode and Flowchart. Pseudocode is an informal high-level description of the operating principle of a computer program or other algorithm. It is the Natural Language representation of a Program or algorithm
E N D
CS 101 INTRODUCTION TO COMPUTER SCIENCES DEPARTMENT OF COMPUTER SCIENCES
Pseudocode and Flowchart • Pseudocode is an informal high-level description of the operating principle of a computer program or other algorithm. • It is the Natural Language representation of a Program or algorithm • It uses the structural conventions of a programming language, but is intended for human reading rather than machine reading • It is used to explain a program to someone who may not understand the particular programming language in which it was made
Pseudocode generally does not actually obey the syntax rules of any particular language There is no systematic standard form, although any particular writer will generally borrow style and syntax Popular syntax sources include Pascal, BASIC, C, C++, Java, Lisp, and ALGOL. Variable declarations mostly omitted. Function calls and blocks of code, such as code contained within a loop, are often replaced by a one-line natural language sentence
Function CountToHundred For n = 1 to 100 do print n End _________________________________ Function AccessPassword Read n If n = “zebra” Write “Access Granted” Else write “Access denied” End If
Pascal style pseudocode • procedure fizzbuzz • for i := 1 to 100 do • set print_number to true; • if i is divisible by 3 • then print "Fizz"; • set print_number to false; • if i is divisible by 5 then print "Buzz"; • set print_number to false; • if print_number, print i; • print a newline; • end
Flowchart is the diagrammatical representation of an algorithm. • Steps are described in boxes of various kinds, and their order indicated by connecting them with arrows • Flowcharts are used in analyzing, designing, documenting or managing a process or program.
Symbols Used in Flowchart Design • Terminals: these Symbols (ovals) either indicate the beginning or the end of a process
Process: represented by a rectangle. It is used to denote an active process e.g. “1+2”
Decision: The diamond symbol is used to signify a logical decision or comparison.
Input/output: The Parallelogram is used to signify an input or output from some user or external program