aboutsummaryrefslogtreecommitdiff
path: root/CST116-Ch10-Debugging
diff options
context:
space:
mode:
Diffstat (limited to 'CST116-Ch10-Debugging')
-rw-r--r--CST116-Ch10-Debugging/CST116-Ch10-Debugging-Output.txt24
-rw-r--r--CST116-Ch10-Debugging/CST116-Ch10-Debugging-PsuedoCode.txt42
-rw-r--r--CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp17
3 files changed, 77 insertions, 6 deletions
diff --git a/CST116-Ch10-Debugging/CST116-Ch10-Debugging-Output.txt b/CST116-Ch10-Debugging/CST116-Ch10-Debugging-Output.txt
new file mode 100644
index 0000000..bb4ede5
--- /dev/null
+++ b/CST116-Ch10-Debugging/CST116-Ch10-Debugging-Output.txt
@@ -0,0 +1,24 @@
+Please enter your first name: Jo
+
+Please enter your last name: johm
+
+
+ Welcome Jo johm!
+ Hope all is well
+
+ x y z
+
+ 0 100 -99
+ 99 101 102
+ 2 102 104
+ 3 103 106
+ 4 104 108
+ 5 105 110
+ 6 106 112
+ 7 107 114
+ 8 108 116
+ 9 109 118
+
+C:\Users\wythe\Desktop\Homework\C++\cst116-ch10-debugging-johnson\CST116-Ch10-Debugging\x64\Debug\CST116-Ch10-Debugging.exe (process 24412) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . . \ No newline at end of file
diff --git a/CST116-Ch10-Debugging/CST116-Ch10-Debugging-PsuedoCode.txt b/CST116-Ch10-Debugging/CST116-Ch10-Debugging-PsuedoCode.txt
new file mode 100644
index 0000000..7714581
--- /dev/null
+++ b/CST116-Ch10-Debugging/CST116-Ch10-Debugging-PsuedoCode.txt
@@ -0,0 +1,42 @@
+constant int SIZE = 5
+
+instantiate 3 integer arrays with size of SIZE, their names will be varX, varY, varZ
+
+
+GetAndDisplayWelcomeInfo()
+{
+create a 2 dimensional array of characters with name 'name'
+its size will be [2][20]
+
+set name[0] to user inputed first name
+set name[1] to user inputed second name
+
+print welcome message, "Welcome name[0] + name[1]. Hope all is well"
+}
+
+FunctionOne(int varX[], int varY[])
+{
+for(x=0, x<SIZE, x++) set varX[x] = x, set varY[x] = x + 100
+}
+
+FunctionTwo(int varX[], const int varY[], int varZ[])
+{
+for(x=0, x<SIZE, x++) set varZ[x] = varX[x] + varY[x]
+
+
+set varX[1] to 99
+}
+
+set varZ[0] to -99
+
+PrintFunction(const int varX[20], const int varY[20], const int varZ[20])
+{
+int x;
+print "x y z"
+for(x=0, x<SIZE, x++) print out varX[x] + varY[x] + varZ[x]
+
+}
+
+return 0;
+
+
diff --git a/CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp b/CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp
index 1e3d58b..4acecc8 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,9 @@ int main()
// Breakpoint 3
// Put breakpoint on the following line
FunctionTwo(varX, varY, varZ);
+
+ varZ[0] = -99;
+
PrintFunction(varX, varY, varZ);
return 0;
@@ -122,17 +125,19 @@ void GetAndDisplayWelcomeInfo()
void FunctionOne(int varX[], int varY[])
{
for (int x = 0; x < SIZE; x++) // NOTICE '<' NOT <=
+ {
// Breakpoint 4
// Put breakpoint on the following line
varX[x] = x;
-
- for (int x = 0; x < 5; x++)
varY[x] = x + 100;
+ }
}
-void FunctionTwo(const int varX[], const int varY[], int varZ[])
+void FunctionTwo(int varX[], const int varY[], int varZ[])
{
for (int x = 0; x < SIZE; x++) // Notice the const SIZE here
varZ[x] = varX[x] + varY[x];
+ varX[1] = 99;
+
}
void PrintFunction(const int varX[20], const int varY[20],
const int varZ[20])