aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMusa Ahmed <[email protected]>2022-10-19 16:55:25 -0700
committerMusa Ahmed <[email protected]>2022-10-19 16:55:25 -0700
commite560d475a438f1fd4b5f9977e96a9145e350a4f8 (patch)
tree8a0297cee88a09e032fffe80c2b1dd894647345d
parentdid debugging exercises (diff)
downloadcst116-ch9-debugging-m005a-e560d475a438f1fd4b5f9977e96a9145e350a4f8.tar.xz
cst116-ch9-debugging-m005a-e560d475a438f1fd4b5f9977e96a9145e350a4f8.zip
Added the pseudocode txt
-rw-r--r--CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.cpp15
-rw-r--r--CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.vcxproj3
-rw-r--r--CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.vcxproj.filters5
-rw-r--r--CST116-Ch9-Debugging-Ahmed/cst116-ch9-Debugging-Ahmed.txt19
-rw-r--r--CST116-Ch9-Debugging-Ahmed/lab1.pdfbin0 -> 147668 bytes
5 files changed, 36 insertions, 6 deletions
diff --git a/CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.cpp b/CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.cpp
index beb37f6..00ef3ff 100644
--- a/CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.cpp
+++ b/CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.cpp
@@ -17,7 +17,8 @@
* 8) Step into one more time.
* 9) Why did the address of age and value change?
* The address changed becasue we re-instantiated the variable age in the function,
-* but we didn't specify a number for it so it's just filled wiht garbage
+* so it is basically a completely different variable, but we didn't specify a number
+* for it so it's just filled with garbage
* 10) Step over the cout and cin statements.
* 11) Verify the value entered is stored properly in age.
* 12) Step into until the flow returns to main.
@@ -40,7 +41,7 @@
* 4) Step into one more time so that the current line is the
* calculation.
* 5) Why is age greyed out in your watch window?
-* It's not greyed out. I followed every step but its not greyed out for me
+* age is not within the scope of CalcDays.
* 6) Stop debugging.
*
* Debugging Exercise 3
@@ -71,7 +72,8 @@ using std::cout;
using std::cin;
using std::endl;
-int age = 0;
+
+
const int DAYS_PER_YEAR = 365;
@@ -81,12 +83,13 @@ void PrintResults(int age, int days);
int main()
{
-
+ int age = 0;
int days = 0;
+
// Breakpoint 1
// Put breakpoint on the following line
- GetAge();
+ age = GetAge();
days = CalcDays(age);
// Breakpoint 2
@@ -97,7 +100,7 @@ int main()
}
int GetAge()
{
-
+ int age;
cout << "Please enter your age: ";
cin >> age;
diff --git a/CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.vcxproj b/CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.vcxproj
index 03b8aa4..4388c12 100644
--- a/CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.vcxproj
+++ b/CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.vcxproj
@@ -129,6 +129,9 @@
<ItemGroup>
<ClCompile Include="CST116-Ch9-Debugging-Ahmed.cpp" />
</ItemGroup>
+ <ItemGroup>
+ <Text Include="cst116-ch9-Debugging-Ahmed.txt" />
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
diff --git a/CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.vcxproj.filters b/CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.vcxproj.filters
index 08d805a..c2c9dbe 100644
--- a/CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.vcxproj.filters
+++ b/CST116-Ch9-Debugging-Ahmed/CST116-Ch9-Debugging-Ahmed.vcxproj.filters
@@ -19,4 +19,9 @@
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
+ <ItemGroup>
+ <Text Include="cst116-ch9-Debugging-Ahmed.txt">
+ <Filter>Source Files</Filter>
+ </Text>
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/CST116-Ch9-Debugging-Ahmed/cst116-ch9-Debugging-Ahmed.txt b/CST116-Ch9-Debugging-Ahmed/cst116-ch9-Debugging-Ahmed.txt
new file mode 100644
index 0000000..1d80833
--- /dev/null
+++ b/CST116-Ch9-Debugging-Ahmed/cst116-ch9-Debugging-Ahmed.txt
@@ -0,0 +1,19 @@
+Start Program
+
+Initialize a constant integer "DAYS_PER_YEAR" to 365
+Initialize a function GetAge()
+Initialize a function CalcDays() which passes the age
+Initialize a function PrintResults() which passes age and days, both are ints
+Initialize the iintegers age and days
+
+Run the fucntion GetAge()
+ Prompt the user for their age
+ Store it into the variable age
+Run the function CalcDays(age)
+ Perform the multiplication of DAYS_PER_YEAR and age
+ Return the integer days
+Store the output from the previous function to the int days
+Run th efunction PrintResults(age,days)
+ print the users age, and tell them how many days old they are
+
+End Program \ No newline at end of file
diff --git a/CST116-Ch9-Debugging-Ahmed/lab1.pdf b/CST116-Ch9-Debugging-Ahmed/lab1.pdf
new file mode 100644
index 0000000..56c50e0
--- /dev/null
+++ b/CST116-Ch9-Debugging-Ahmed/lab1.pdf
Binary files differ