
Patrick B. answered 01/14/21
Math and computer tutor/teacher
1)
If the same piece of code is to be written and executed
over and over again, it is a candidate for MODULAR program,
or sub-program
A block of code that is given a name and executed when
called upon. The module can be designed to take input parameters
and return one or more values to the caller
2) input validation: ensuring that the input provided by
the user meets specific requirements and criteria
For example, input the numbers to divide....
N is hte numerator, D is the denominator which cannot be zero...
the loops until the user DOES NOT input zero for D
Important because the program will get invalid input and crash
3) output "Please input the number to divide "
input Numerator
denominator =0
while denominator equals zero
out "Please input the denominator "
input denominator
endwhile
4) Must be given a size N....
a collection of N variables of the SAME TYPE,
STORED SEQUENTIALLY in the memory
5)
type array-name[size];
EX. int A[100]; <--- array of 100 integers
double amounts[100] <--- array of 100 double floats
the first item in the array is at position ZER0
the 2nd item in the array is at position 1
the 3rd item in the array is at position 2
etc.
the LAST item in the array is a position N-1
so A[5] is the 6th integer in the array
typically, attempting to access the item out-of-bounds
is a run time error
6-7) Sorting: arranging the items in the array in either
increasing or decreasing order
'Bubble sort
For iIndexPos = N-1,N-2,N-3,...,5,4,3,2,1
for jLoop=0 to iIndexPos-1
if Array[jLoop]>Array[jLoop+1] then
SWAP Array[jLoop] and Array[jLoop+1]
endif
endfor jLoop
end for iIndexPos