aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei F <[email protected]>2022-10-12 12:38:07 -0700
committerAndrei F <[email protected]>2022-10-12 12:38:07 -0700
commit3754122a0ba34e6f1fc01d584eb97d73f84d4259 (patch)
treef029c293339d52452d7657c4b960005545b2effa
parentAnother commit (diff)
downloadcst116-ch6-debugging-florea-3754122a0ba34e6f1fc01d584eb97d73f84d4259.tar.xz
cst116-ch6-debugging-florea-3754122a0ba34e6f1fc01d584eb97d73f84d4259.zip
Finished Exercise 2
-rw-r--r--CST116-Ch6-Debugging/CST116-Ch6-Debugging-Florea.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/CST116-Ch6-Debugging/CST116-Ch6-Debugging-Florea.cpp b/CST116-Ch6-Debugging/CST116-Ch6-Debugging-Florea.cpp
index fd34981..80059a1 100644
--- a/CST116-Ch6-Debugging/CST116-Ch6-Debugging-Florea.cpp
+++ b/CST116-Ch6-Debugging/CST116-Ch6-Debugging-Florea.cpp
@@ -48,6 +48,12 @@
* c) replace the 5 with 5.0 and the 9 with 9.0
* 7) Stop debugging, recompile and run to verify that it now works
* correctly.
+ *
+ * After type casting one of the integer literals, instead of integer division,
+ * it will now be float point division. I don't have to type cast both literals, just one
+ * of them will work. Now, if I input 212 degrees for Fahrenheit, it will output
+ * 100 degrees Celsius.
+ *
********************************************************************/
#include <iostream>
@@ -66,7 +72,7 @@ int main()
// Breakpoint 1
// Put a breakpoint on the following line
- celcius = 5 / 9 * (fahrenheit - 32);
+ celcius = (float) 5 / 9 * (fahrenheit - 32);
cout << fahrenheit << " degrees F = "
<< celcius << " degrees C" << endl;