S2 - Programming (Done) Flashcards
What are the main data types ?
Integer(INT), real(or float)(REAL), boolean(BOOL), character(CHAR), string(STRING).
How much memory does an integer take up ?
2 bytes or 4 bytes.
How much memory does an real take up ?
4 bytes or 8 bytes.
How much memory does an boolean take up ?
1 bit is needed but 1 byte usually used.
How much memory does an character take up ?
1 byte.
How much memory does an string take up ?
1 byte for every character in the string.
How do you change from a string to an integer in pseudo-code ?
STRING_TO_INT( ‘1’ )
How do you change from an integer to an string in pseudo-code ?
INT_TO_STRING( 1 )
How do you change from a string to a real in pseudo-code ?
STRING_TO_REAL( ‘1’ )
How do you change from a real to a string in pseudo-code ?
REAL_TO_STRING( 1.0 )
What are the basic arithmetic operators ?
Addition, subtraction, multiplication, division, integer division(DIV) - only works with integers and remainder(MOD or %) - only works with integers.
What is a constant ?
Something that can’t be changed in the program, trying to will result in an error. They’re assigned a value at design time.
What is a variable ?
Something that can be changed, meaning that a variables value can be changed at any point throughout the program making them much more useful than constants.
What does the string manipulation LEN(string) do ?
Returns the number of characters in that string.
What does the string manipulation POSITION(string, character) do ?
Returns the position of the occurrence of a certain character in a given string.
What does the string manipulation SUBSTRING(x, y, string) do ?
Extracts a substring from the original string starting at position x and finishing at position y.
What is a nested IF statement ?
An IF statement inside another IF statement, allowing you to check more conditions once you’ve established that the previous condition is true or false.
What are ELSE-IF statements ?
Used to check multiple conditions and give different outputs depending on which condition is true, different from nested IF statements as they only check more conditions if the first one is false.
What is a CASE statement ?
They check the value of a variable, used when you want the program to perform different actions for different values of the same variable.
What is a repeat-until loop ?
Controlled by a condition at the end, keeps going until condition is true, always run the code inside them at least once and you get an infinite loop if condition is never true.
What is a while loop ?
Controlled by a condition at the start, keeps going while condition is true, never run the code inside if condition is initially false and you get an infinite loop if the condition is always true.
What is a do-while loop ?
Controlled by a condition at the end, keeps going while condition is true, always run the code inside them at least once and you get an infinite loop if the condition is always true.