[Unit 2.2] Problem Solving and Programming Flashcards
Algorithms and Programming
define constant
a label to represent a value stored in memory that cannot change while the program is running
define variable
a label to represent a value stored in memory that can change while the program is running
define casting
changing a value from one data type to another
define global variables
can be accessed anywhere in the program. They must be stored in memory for duration of execution
define local variables
can only be accessed in a certain part of the program. Usually local to a subroutine and declared within.
Why don’t we use global variables?
they use a lot more memory. its harder to locate errors as global variables can be updated anywhere
difference between implicit and explicit casting?
implicit there is no loss of accuracy (int->long)
Explicit there may be loss of accuracy (double->int)
define sequence
program is followed one instruction after another
define Selection
Decision is made based on state of Bool (if..else)(switch..case)
define Iteration
repetition of a section of code using a loop
difference between count and condition controlled loop
count controlled runs a set number of times
condition controlled runs till a condition is met
difference between a pre and post check on a condition controlled loop
pre check - condition checked at start of loop
post check - condition checked at end of loop
define Function
subprogram that usually returns a value
define procedure
subprogram that performs some operation but does not return a value
define Parameter
variables that the subroutine receives (variable in the sub)
define Argument
variable that you pass into the subroutine (variable in the program)
define by value parameter
variable is copied, changing the value in the sub doesn’t change the original value
define by reference parameter
subroutine works with the original data/variable. If it changes, it stays changed
define Recursion
When a subprogram calls itself.
key features of recursion (2)
base condition (stop the loop)
recursion statement
(Dis)advantages of recursion
Dis:
-less efficient
-uses more memory
-may overflow stack due to too many calls (crashes)
-difficult to trace
Ad:
-quicker to write
-easier to read
-some problems are naturally recursive
Features of IDE (9)
syntax highlighting
code editors
debugging tools
RTE
version control
automatic line numbers
keyword highlighting
automatic formatting
autocomplete
define syntax highlighting
checks and highlights syntax errors
define code editors
write and edit code