Comp 1312 Programming 1 Flashcards
What does an f string do?
An f string tells python to sub in all the variables, placed inside the curly brackets into the string
What are the concepts for quality code?
Duplication
Coupling
Cohesion
What is duplication?
An indicator of bad design where code has been copied, harder to maintain.
What is coupling?
Links between separate modules of a program
We aim for loose coupling.
What is loose coupling?
Understanding one item without reading another so we can change one function without changing another.
What is the Noun/Verb method?
Identifying nouns to reveal potential identifiers.
What is C?
Imperative procedural programming language, compiled, statically typed with low-level access.
What is a header file?
How extra modules are imported in C
List some default types in C
INT
FLOAT
DOUBLE
CHAR
_Bool
What are type specifiers?
Keywords that change the amount of data associated with a type
What happens if we initialise a variable at it’s highest value and then add one?
An overflow
What is implicit type conversion?
When a type can be converted to another without specific instructions to do so, e.g integer to float.
What does the Const keyword do?
Makes the variable constant and thus read only
What is the difference between ++n and n++?
Pre-increment and post-increment
What are strings really?
Arrays of chars
What is the placeholder symbol for a string?
%s
What is a structure?
Group elements of different types into one object
What can a structure be considered to be?
A data template
How can a structure be accessed?
structure_name.structure_item;
What does typedef do?
Assigns a new name to existing types and new data types, including structures
typedef int counter;
counter x,y;
T/F A function can return an array.
False
T/F A function can return an structure.
True
T/F You can have nested structures
True
What is a pointer?
A variable that stores a memory address
What could be an issue when memory is not cleared correctly?
Any variables declared get whatever value is at the location they are assigned
What does the sizeof function return?
The number of bytes taken up by the type submitted as it’s operand.
How can you calculate the length of an array?
sizeof(array)/sizeof(type)
What is the symbol for the address operator?
&
What would &var return?
The address the var variable is being stored at.
How can a pointer be declared?
double *p = &var;
Why is a type declared with a pointer?
So the pointer knows how many bytes belong to the variable.
What is the dereference operator?
*p
This is the same as just accessing a variable