Week 1 - C Flashcards

1
Q

What qualities should we look out for in our code to make sure they are well designed?

A
  1. Correctness - if our code works correctly and how as intended
  2. Design - Based on how efficient and how easily readable it is
  3. Style - how aesthetically formatted our code is, in terms of consistent indentation and other placement of symbols.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the two kind of outputs functions can have?

A
  1. side effects - such as something printed on a screen
  2. return values - a value that is passed back to our program that we can use or store for later.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly