diff options
| author | Andrei F <[email protected]> | 2022-10-12 21:48:20 -0700 |
|---|---|---|
| committer | Andrei F <[email protected]> | 2022-10-12 21:48:20 -0700 |
| commit | d135618af6d162965c0e7c2a17d3a4fb6bc8e424 (patch) | |
| tree | 674389389d5f7f271d300a4b54fb99bedee87f10 | |
| parent | Adding gitignore file (diff) | |
| download | cst116-ch7-debugging-florea-d135618af6d162965c0e7c2a17d3a4fb6bc8e424.tar.xz cst116-ch7-debugging-florea-d135618af6d162965c0e7c2a17d3a4fb6bc8e424.zip | |
Finished Exercise 1
| -rw-r--r-- | .idea/.gitignore | 8 | ||||
| -rw-r--r-- | .idea/.name | 1 | ||||
| -rw-r--r-- | .idea/cst116-ch7-debugging-florea.iml | 2 | ||||
| -rw-r--r-- | .idea/misc.xml | 4 | ||||
| -rw-r--r-- | .idea/modules.xml | 8 | ||||
| -rw-r--r-- | .idea/vcs.xml | 6 | ||||
| -rw-r--r-- | CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 32 |
7 files changed, 54 insertions, 7 deletions
diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..92871d2 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +cst116_ch7_debugging_florea
\ No newline at end of file diff --git a/.idea/cst116-ch7-debugging-florea.iml b/.idea/cst116-ch7-debugging-florea.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/.idea/cst116-ch7-debugging-florea.iml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module classpath="CMake" type="CPP_MODULE" version="4" />
\ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..79b3c94 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" /> +</project>
\ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..9414806 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/cst116-ch7-debugging-florea.iml" filepath="$PROJECT_DIR$/.idea/cst116-ch7-debugging-florea.iml" /> + </modules> + </component> +</project>
\ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$" vcs="Git" /> + </component> +</project>
\ No newline at end of file diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp index f64adfe..e2e7bbd 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -11,9 +11,16 @@ * 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.
+ *
+ * Done, the age value is set to my input which is 19.
+ *
* 5) Step over the if statement.
* 6) Why did the value in age change?
-* 7) Fix the problem and repeat Steps 2 � 5 to verify the
+ *
+ * The value of age changed because the if comparison were not correctly written, there was only a single = sign,
+ * which means that it would assign a value to a variable.
+ *
+* 7) Fix the problem and repeat Steps 2 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
*
@@ -26,7 +33,10 @@ * 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?
-* 7) Fix the problem and repeat Steps 1 � 5 to verify the
+ *
+ * The problem is that on the fi
+ *
+* 7) Fix the problem and repeat Steps 1 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
* 9) Remove Breakpoint1.
@@ -56,18 +66,26 @@ 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)
+ }
+ 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;
+ {
+ cout << "Adult" << endl;
+ }
return 0;
}
\ No newline at end of file |