Chapter 8
Chapter 8
Muhi U Din
Lets see an example of an incorrect pseudo code and its output compared with the correct one and its
output
Computer Science Chapter 8 - Programming M. Muhi U Din
Computer Science Chapter 8 - Programming M. Muhi U Din
Pre-condition loop is run when the condition is met. (the condition is checked before)
Post-condition loop is run first and then the condition is checked.
Computer Science Chapter 8 - Programming M. Muhi U Din
Practice question:
Write a program in which marks of ten students in an array of marks[] are checked. The marks
must be between 0 and 100, and if the marks are 0-49 then print “fail” else print “pass”
Function
Functions is like a procedure except it always returns a value.
The keyword RETURN is used as one of the statements in a function to specify the value to be
returned.
A function call must match the function definition. The arguments in the function call should
match the parameters in the procedure definition.
When procedure and functions are defined, the first statement in the definition is a header,
which contains:
8.2 Arrays
An array is a data structure containing several elements of the same data type. These elements
can be accessed using the same identifier name with position of each elements in an array
(index)
When a two dimensional array is declared in pseudo code, the followings are included: