aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevidavis04 <[email protected]>2022-10-12 18:42:36 -0700
committerGitHub <[email protected]>2022-10-12 18:42:36 -0700
commit298bc02599ebd13d331141b0644a2768ec30c014 (patch)
treefcacac1c572a9c8476742e9944fe958c131b81e1
parentInitial commit (diff)
downloadcst116-chapter8-debugging-levidavis04-298bc02599ebd13d331141b0644a2768ec30c014.tar.xz
cst116-chapter8-debugging-levidavis04-298bc02599ebd13d331141b0644a2768ec30c014.zip
Add files via upload
-rw-r--r--CST116-Ch7-Debug-OUTPUT-Davis.rtf22
-rw-r--r--CST116-Ch8-Debug-Davis.cpp76
-rw-r--r--CST116-Ch8-Debug-PSEUDOCODE-Davis.rtf17
3 files changed, 115 insertions, 0 deletions
diff --git a/CST116-Ch7-Debug-OUTPUT-Davis.rtf b/CST116-Ch7-Debug-OUTPUT-Davis.rtf
new file mode 100644
index 0000000..30904bc
--- /dev/null
+++ b/CST116-Ch7-Debug-OUTPUT-Davis.rtf
@@ -0,0 +1,22 @@
+{\rtf1\ansi\ansicpg1252\cocoartf2639
+\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Menlo-Bold;}
+{\colortbl;\red255\green255\blue255;\red255\green255\blue255;\red31\green31\blue36;}
+{\*\expandedcolortbl;;\csgenericrgb\c100000\c100000\c100000;\csgenericrgb\c12054\c12284\c14131;}
+\margl1440\margr1440\vieww11520\viewh8400\viewkind0
+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
+
+\f0\fs24 \cf0 Output: \
+\pard\tx593\pardeftab593\pardirnatural\partightenfactor0
+
+\f1\b \cf2 \cb3 0\
+1\
+2\
+3\
+4\
+5\
+6\
+7\
+8\
+9\
+10\
+Program ended with exit code: 0} \ No newline at end of file
diff --git a/CST116-Ch8-Debug-Davis.cpp b/CST116-Ch8-Debug-Davis.cpp
new file mode 100644
index 0000000..ee2fa3b
--- /dev/null
+++ b/CST116-Ch8-Debug-Davis.cpp
@@ -0,0 +1,76 @@
+//
+// main.cpp
+// CST116 Chapter 8 Debugging exercises Levi Davis
+//
+// Created by Levi on 10/12/22.
+//
+/********************************************************************
+* File: CST116-Ch8-Debugging.cpp
+*
+* General Instructions: Complete each step before proceeding to the
+* next.
+*
+* Debugging Exercise 1
+*
+* 1) Insert a breakpoint on the lines indicated in the code.
+* 2) Run to Breakpoint 1.
+* 3) Place a watch on i.
+* 4) Execute the while statement by doing a "Step Into".
+* 5) The execution continues to the cout statement as expected.
+* 6) Step over the cout statement.
+* 7) Why didn't the flow of the program return back to the while
+* statement?
+* 8) Fix this problem by removing the ; after the while statement.
+* 9) Stop debugging and repeat Steps 2 – 5 to verify the correction
+* worked.
+* 10) Stop debugging.
+*
+* Debugging Exercise 2
+*
+* 1) Run to Breakpoint 1.
+* 2) Step into the while loop.
+* 3) Why did the cout not execute?
+* 4) Check the value of i, now check the condition, does the
+* condition evaluate to true?
+* 5) Change the "< 0" to a "< 10".
+* 6) Stop debugging and repeat Steps 1 – 4 to verify the correction
+* worked.
+* 7) Stop debugging.
+*
+* Debugging Exercise 3
+*
+* 1) Run the program without debugging.
+* 2) What is happening now is an infinite loop.
+* 3) End your program by holding down the Ctrl key and pressing C.
+* 4) Fix the problem by adding a "++" after the i in the cout
+* statement.
+* 5) Run the program to Breakpoint 2 and verify that the output
+* displayed on the screen is 0 – 9.
+*
+* Debugging Exercise 4
+*
+* 1) Run to Breakpoint 2.
+* 2) Add a watch to the variable count.
+* 3) Verify that the contents of count is garbage.
+* 4) Step into the loop.
+* 5) What is the value stored in count now? (2)
+* 6) Where was 10 assigned to count? (at the second cout statement)
+* 7) Fix the problem and re-run to verify.
+********************************************************************/
+#include <iostream>
+using std::cout;
+using std::endl;
+
+int main()
+{
+ int i = 0;
+ int count;
+
+ while (i < 10)
+ cout << i ++ << endl;
+
+ for (count = 0; count < 10; count++);
+ cout << count << endl;
+
+ return 0;
+}
diff --git a/CST116-Ch8-Debug-PSEUDOCODE-Davis.rtf b/CST116-Ch8-Debug-PSEUDOCODE-Davis.rtf
new file mode 100644
index 0000000..d22d6d0
--- /dev/null
+++ b/CST116-Ch8-Debug-PSEUDOCODE-Davis.rtf
@@ -0,0 +1,17 @@
+{\rtf1\ansi\ansicpg1252\cocoartf2639
+\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+{\*\expandedcolortbl;;}
+\margl1440\margr1440\vieww11520\viewh8400\viewkind0
+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
+
+\f0\fs24 \cf0 Pseudo Code\
+\
+Set i = 0\
+Count = i\
+While I <10\
+ i + 1\
+For count = 0 count also < 10 count = count + 1\
+Print Count\
+\
+Return count and i = 0} \ No newline at end of file