diff options
| author | JonCr <[email protected]> | 2022-10-28 02:12:56 -0700 |
|---|---|---|
| committer | JonCr <[email protected]> | 2022-10-28 02:12:56 -0700 |
| commit | 12024f70066009960ec10e0c3ac0c1a27252834f (patch) | |
| tree | efc1e65da0c6dd4ece68b006d0d2c734ef6fbacc | |
| parent | Setting up GitHub Classroom Feedback (diff) | |
| download | cst116-ch10-debugging-cognitiveshadow-main.tar.xz cst116-ch10-debugging-cognitiveshadow-main.zip | |
| -rw-r--r-- | CASt116-Ch10-Crombie-pseudocode.txt | 33 | ||||
| -rw-r--r-- | CST116-Ch10-Crombie.txt | 20 | ||||
| -rw-r--r-- | CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp | 12 |
3 files changed, 60 insertions, 5 deletions
diff --git a/CASt116-Ch10-Crombie-pseudocode.txt b/CASt116-Ch10-Crombie-pseudocode.txt new file mode 100644 index 0000000..d1c79a4 --- /dev/null +++ b/CASt116-Ch10-Crombie-pseudocode.txt @@ -0,0 +1,33 @@ +Declare functions +Set constant SIZE equal to 10 +Run function main + Create array varX + Create array varY + Create array varZ + Run function GetAndDisplayWelcomeInfo + Create array name + Print "Please enter your first name: " + Input name[0] + Print "Please enter your last name: " + Input name[1] + Print "Welcome" name[0] " " name[1] "Hope all is well" + Run function FunctionOne + Set x equal to 0 + For x less than SIZE + set varX[x] equal to x + Increase x by 1 + Set x equal to 0 + For x less than SIZE + Set varY[x] equal to x plus 100 + Increase x by 1 + Run function FunctionTwo + Set varX[1] equal to 99 + Set x equal to 0 + For x less than SIZE + Set varZ[x] equal to varX[x] plus varY[x] + Set varZ[0] equat to -99 + Run function PrintFunction + Print " x y z" + Set x equal to 0 + For x less than SIZE + Print varX[x], varY[x], and varZ[x]
\ No newline at end of file diff --git a/CST116-Ch10-Crombie.txt b/CST116-Ch10-Crombie.txt new file mode 100644 index 0000000..d0647ea --- /dev/null +++ b/CST116-Ch10-Crombie.txt @@ -0,0 +1,20 @@ +Please enter your first name: Jonathan + +Please enter your last name: Crombie + + + Welcome Jonathan Crombie! + Hope all is well + + x y z + + 0 100 -99 + 99 101 200 + 2 102 104 + 3 103 106 + 4 104 108 + 5 105 110 + 6 106 112 + 7 107 114 + 8 108 116 + 9 109 118
\ No newline at end of file diff --git a/CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp b/CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp index 1e3d58b..fd1db97 100644 --- a/CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp +++ b/CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp @@ -80,15 +80,15 @@ using std::setw; void GetAndDisplayWelcomeInfo();
void FunctionOne(int varX[], int varY[]);
-void FunctionTwo(const int varX[], const int varY[], int varZ[]);
+void FunctionTwo(int varX[], const int varY[], int varZ[]);
void PrintFunction(const int varX[], const int varY[],
const int varZ[]);
-const int SIZE = 5;
+const int SIZE = 10;
int main()
{
- int varX[5];
+ int varX[SIZE];
int varY[SIZE];
int varZ[SIZE]; // Notice how we used the const here!
@@ -100,6 +100,7 @@ int main() // Breakpoint 3
// Put breakpoint on the following line
FunctionTwo(varX, varY, varZ);
+ varZ[0] = -99;
PrintFunction(varX, varY, varZ);
return 0;
@@ -126,11 +127,12 @@ void FunctionOne(int varX[], int varY[]) // Put breakpoint on the following line
varX[x] = x;
- for (int x = 0; x < 5; x++)
+ for (int x = 0; x < SIZE; x++)
varY[x] = x + 100;
}
-void FunctionTwo(const int varX[], const int varY[], int varZ[])
+void FunctionTwo (int varX[], const int varY[], int varZ[])
{
+ varX[1] = 99;
for (int x = 0; x < SIZE; x++) // Notice the const SIZE here
varZ[x] = varX[x] + varY[x];
}
|