From 3754122a0ba34e6f1fc01d584eb97d73f84d4259 Mon Sep 17 00:00:00 2001 From: Andrei F Date: Wed, 12 Oct 2022 12:38:07 -0700 Subject: Finished Exercise 2 --- CST116-Ch6-Debugging/CST116-Ch6-Debugging-Florea.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'CST116-Ch6-Debugging/CST116-Ch6-Debugging-Florea.cpp') 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 @@ -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; -- cgit v1.2.3