diff options
| -rw-r--r-- | CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp index f64adfe..51ec3ee 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -10,9 +10,9 @@ * 2) Run to Breakpoint 1.
* 3) When prompted, enter your age.
* 4) When the execution stops, add a watch on age and verify that
-* the value in age is what you typed in.
+* the value in age is what you typed in.
* 5) Step over the if statement.
-* 6) Why did the value in age change?
+* 6) Why did the value in age change? // Because the line stating that age = 1 was executed by stepping over it.
* 7) Fix the problem and repeat Steps 2 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -47,27 +47,28 @@ using std::cout; using std::endl;
using std::cin;
-int main()
-{
+int main(){
int age = 0;
-
- cout << "Enter your age: ";
+ cout << "Enter your age: " << endl;
cin >> age;
// 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)
+ } else if (age >= 12 || age <= 19) {
cout << "Teenager" << endl;
- else if (age < 12)
+ } else if (age < 12) {
cout << "Child" << endl;
- else if (age > 62)
+ } else if (age > 62) {
cout << "Senior" << endl;
+ }
// Breakpoint 2
// Put a breakpoint on the following line
- else;
- cout << "Adult" << endl;
+ else {
+ cout << "Adult" << endl;
+ }
return 0;
-}
\ No newline at end of file +}
+
|