Programming Flashcards
What are the 5 main data types?
- Integer (INT)
- Real/ float (REAL)
- Boolean (BOOL)
- Character/char (CHAR)
- String (STRING)
What do the main data types store?
> Integer - whole numbers,
Real - numbers with decimals,
Boolean - true or false,
Character - a single letter, number or symbol,
String - used to represent text, can hold a collection of characters (cannot do maths).
What is the typical amount of memory taken up from the main data types? (in order)
1) Real - 4 Bytes or 8 Bytes,
2) Integer - 2 Bytes or 4 Bytes,
3) String - 1 Byte per character,
4) character - 1 Byte,
5) Boolean - 1 bit is needed but 1 byte is often used.
Is it possible to change one data type to another?
Yes, most languages do allow you to convert data types.
What does an assignment look like in pseudocode?
←
What are examples of selection?
If/Case, Though case is not used in pseudocode, it is specific to certain programming languages like VB.
What are the two types of iteration?
> Definite - a known number of loops at the start of the iteration,
Indefinite - loops until a condition is met.
What are examples of indefinite iteration?
While loops
What are examples of definite iteration?
For loops
What does DIV do?
Divides a number to the nearest whole number without going over, for example: 20 DIV 3 = 6
What does MOD do?
Gives you the remainder of a division, for example: 20 MOD 3 = 2
What is a constant?
A variable where data is assigned and then cannot be changed.
What is a variable?
A location where data values can be stored as a certain file type.
What is the difference between a constant and a variable?
The data in a constant cannot change but a variables data can.
How do you create a random number in Pseudocode?
RANDOM_INT(x, y)
What are arrays?
A data structure that an store a group of data values of the same type. a[]
What is it called when array already has data assigned to indexes?
Prepopulated
What does a prepopulated 1D array look like in pseudocode?
a ← [‘Denial’, ‘lebron’, ‘Nig’, ‘Cmon’]
What are 2D arrays?
The same as an array but with columns and rows instead of just one list. a[x][y] or a[x, y]
What does a prepopulated 2D array look like in pseudocode?
a ← [[‘Joe’, ‘Momma’], [‘Nig’, ‘Cmon’]]
What is a record?
Similar to an array but stores multiple data types. Each item stored in a record is called a field and can have a different data type assigned to it.
How do you declare a record?
RECORD [name of record]
[data type] [name of field]
[data type] [name of field]
ENDRECORD
How do you assign values to a record?
record
Can you use an array to store records?
Yes, if they have the same record structure.
Why do we use files in programming?
To permanently store data when the program closes since the program loses all data once finished.
You can read or write to a file by using WRITELINE() or WRITE()/ READLINE() or READ.
How do you open and close a file in a program?
Variable
Why do we use subroutines and functions?
- Code can be repeated instead of rewritten,
- Code can be edited without effecting the rest of the program,
- Variables can be stored locally instead of taking up extra memory globally.
What is the difference between subs and functions?
Functions return a value.