Embercode
✕
C++ Variables and Data TypesQuick quiz

Floats and division by zero

8 questions. Covers Division by zero.

Questions 1 to 5 of 8

  1. 1. What does this program print? ``cpp #include <iostream> int main() { double zero = 0.0; double a = 1.0 / zero; double b = -1.0 / zero; std::cout << a << " " << b << " " << (a > 1e308) << "\n"; } ``
  2. 2. What does this program print? ``cpp #include <iostream> int main() { double x = 0.5 + 0.25; std::cout << std::boolalpha; std::cout << (x == 0.75) << " " << (0.1 + 0.2 == 0.3) << "\n"; } ``
  3. 3. What does this program print? ``cpp #include <iostream> int main() { double big = 1e16; std::cout << std::boolalpha << (big + 1.0 == big) << "\n"; } ``
  4. 4. Is this statement true? 0.1 + 0.2 == 0.3 is true in C++.
  5. 5. Is this statement true? 0.0 / 0.0 == 0.0 / 0.0 is true in C++, since both sides are the same division.

5 question(s) left on this page.