Week 1 - C Flashcards
1
Q
What qualities should we look out for in our code to make sure they are well designed?
A
- Correctness - if our code works correctly and how as intended
- Design - Based on how efficient and how easily readable it is
- Style - how aesthetically formatted our code is, in terms of consistent indentation and other placement of symbols.
2
Q
What are the two kind of outputs functions can have?
A
- side effects - such as something printed on a screen
- return values - a value that is passed back to our program that we can use or store for later.
3
Q
What is truncation and how can we prevent it?
A
Truncation is when precision after the decimal point is lost when using mathematical operators on numbers.
We can cast (or convert) our data type to another data type
Ex. float z = (float) x / (float) y;
the ‘(float)’ converts the integer into a floating point value