From 4ad3a5696ed3c94f58b2f71519479b8d9dc1957b Mon Sep 17 00:00:00 2001 From: alexandra-apetroaei Date: Wed, 26 Oct 2022 18:36:14 -0800 Subject: finished --- CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp | 29 +++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp') diff --git a/CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp b/CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp index 1e3d58b..6e1cd57 100644 --- a/CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp +++ b/CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp @@ -80,26 +80,33 @@ using std::setw; void GetAndDisplayWelcomeInfo(); void FunctionOne(int varX[], int varY[]); -void FunctionTwo(const int varX[], const int varY[], int varZ[]); +void FunctionTwo(const int varX[], const int varY[], const int varZ[]); void PrintFunction(const int varX[], const int varY[], const int varZ[]); -const int SIZE = 5; +const int SIZE = 10; // Notice how we used the const here! int main() { - int varX[5]; + int varX[SIZE]; int varY[SIZE]; - int varZ[SIZE]; // Notice how we used the const here! + int varZ[SIZE]; // Breakpoint 1 // Put breakpoint on the following line GetAndDisplayWelcomeInfo(); + + varX[SIZE] = 99; + varZ[SIZE] = -99; + FunctionOne(varX, varY); + + // Breakpoint 3 // Put breakpoint on the following line FunctionTwo(varX, varY, varZ); + PrintFunction(varX, varY, varZ); return 0; @@ -124,18 +131,18 @@ 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; + varX[SIZE] = 99; - for (int x = 0; x < 5; x++) - varY[x] = x + 100; + for (int x = 0; x <= 10; x++) + varY[SIZE] = x + 100; } void FunctionTwo(const 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]; + for (int x = 0; x <= SIZE; x++) // Notice the const SIZE here + varZ[SIZE] = varX[SIZE] + varY[SIZE]; } -void PrintFunction(const int varX[20], const int varY[20], - const int varZ[20]) +void PrintFunction(const int varX[], const int varY[], + const int varZ[]) { int x; -- cgit v1.2.3