diff options
Diffstat (limited to 'CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp')
| -rw-r--r-- | CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp index f64adfe..b97eb32 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -13,6 +13,7 @@ * the value in age is what you typed in.
* 5) Step over the if statement.
* 6) Why did the value in age change?
+* It used the = in the if statement instead of ==, which changed the value rather than check it
* 7) Fix the problem and repeat Steps 2 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -26,6 +27,7 @@ * 4) Verify that 25 is still stored in age.
* 5) Step over the else if.
* 6) Why is the program going to print "Teenager" for an age of 25?
+* It's checking for values less than or equal to 19 OR greater than or equal to 12, which is all real numbers
* 7) Fix the problem and repeat Steps 1 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -43,9 +45,7 @@ ********************************************************************/
#include <iostream>
-using std::cout;
-using std::endl;
-using std::cin;
+using namespace std;
int main()
{
@@ -56,7 +56,7 @@ int main() // Breakpoint 1
// Put a breakpoint on the following line
- if (age = 1)
+ if (age == 1)
cout << "First Birthday" << endl;
else if (age >= 12 || age <= 19)
cout << "Teenager" << endl;
|