PS 1
- What value does a variable store if you declare it without
assigning a value to it: we write int a for example and then print out
a; what about doubles, floats and chars.
- unassigned.cpp shows that it assigns an apparently random value to the first three and an unprintable one to the char.
- If you take a double from an unsigned int does it cast to a double or a short int?
- Write a short programme that cin's a double and prints out the decimal part.
- decimal.cpp kind of works, though it doesn't deal very elegantly with negative numbers. This is a tiny bit better decimal_if.cpp
- ceil(a) rounds a up and floor(a) rounds it down, write a programme that cin's a double and then rounds it the way we do, up if it the decimal is greater than 0.5 and down otherwise.
- round.cpp does it, notice it deals with negative numbers too. It is worth writing a small programme to observe what int does to a negative number, it is not the same as floor: int_negative.cpp