From 30f694af6449574b630b1a5b36aa4d0896ddad55 Mon Sep 17 00:00:00 2001 From: Musa Ahmed Date: Wed, 12 Oct 2022 11:45:20 -0700 Subject: Renamed & Added Flowchart --- .../CST116-Ch7-Debugging-Ahmed.cpp | 83 ++++++++++++ .../CST116-Ch7-Debugging-Ahmed.sln | 31 +++++ .../CST116-Ch7-Debugging-Ahmed.txt | 24 ++++ .../CST116-Ch7-Debugging-Ahmed.vcxproj | 141 +++++++++++++++++++++ .../CST116-Ch7-Debugging-Ahmed.vcxproj.filters | 32 +++++ .../CST116-Ch7-Debugging-Ahmed.cpp | 83 ------------ .../CST116-Ch7-Debugging-Ahmed.txt | 24 ---- CST116-Ch7-Debugging/CST116-Ch7-Debugging.sln | 31 ----- CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj | 138 -------------------- .../CST116-Ch7-Debugging.vcxproj.filters | 27 ---- .../CST116-Ch7-Debugging.vcxproj.user | 4 - 11 files changed, 311 insertions(+), 307 deletions(-) create mode 100644 CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.cpp create mode 100644 CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.sln create mode 100644 CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.txt create mode 100644 CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.vcxproj create mode 100644 CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.vcxproj.filters delete mode 100644 CST116-Ch7-Debugging/CST116-Ch7-Debugging-Ahmed.cpp delete mode 100644 CST116-Ch7-Debugging/CST116-Ch7-Debugging-Ahmed.txt delete mode 100644 CST116-Ch7-Debugging/CST116-Ch7-Debugging.sln delete mode 100644 CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj delete mode 100644 CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.filters delete mode 100644 CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.user diff --git a/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.cpp b/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.cpp new file mode 100644 index 0000000..9563dba --- /dev/null +++ b/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.cpp @@ -0,0 +1,83 @@ +/******************************************************************** +* File: CST116-Ch7-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) When prompted, enter your age. +* 4) When the execution stops, add a watch on age and verify that +* the value in age is what you typed in. +* 5) Step over the if statement. +* 6) Why did the value in age change? +* In the if statement, the conditional was written as "age = 0" +* instead of "age == 1", thus the age is set to 1 everytime. +* 7) Fix the problem and repeat Steps 2 – 5 to verify the +* problem was corrected. +* 8) Stop debugging. +* +* Debugging Exercise 2 +* +* 1) Run to Breakpoint 1. +* 2) When prompted, enter the value 25 for your age. +* 3) Step over the if statement. Execution of the program should +* continue on the else if statement. +* 4) Verify that 25 is still stored in age. +* 5) Step over the else if. +* 6) Why is the program going to print "Teenager" for an age of 25? +* The else if statement was checking if the age was greater than +* or equal to 12 OR less than or equal to 19. Instead it should be +* checking if the age is between 12 AND 19 inclusively. +* 7) Fix the problem and repeat Steps 1 – 5 to verify the +* problem was corrected. +* 8) Stop debugging. +* 9) Remove Breakpoint1. +* +* Debugging Exercise 3 +* +* 1) Run the program without debugging. +* 2) When prompted, enter the value of 10 for your age. +* 3) Why does the program print both "Child" and "Adult"? +* There is a cout statement at the end of all the else if statements +* which is executing every time main is run. +* 4) Re-run the program this time with debugging and run to +* Breakpoint 2. +* 5) Why is the action with the else executing? +* The else statement has a semicolon at the end of it, so the statement +* is not included in the else statement and runs regardless of any conditions. +* Everytime main is executed, it will print adult at the end. +* 6) Fix the problem and re-run to verify the problem was corrected. +********************************************************************/ + +#include +using std::cout; +using std::endl; +using std::cin; + +int main() +{ + int age = 0; + + cout << "Enter your age: "; + cin >> age; + + // Breakpoint 1 + // Put a breakpoint on the following line + if (age == 1) + cout << "First Birthday" << endl; + else if (age >= 12 && age <= 19) + cout << "Teenager" << endl; + else if (age < 12) + cout << "Child" << endl; + else if (age > 62) + cout << "Senior" << endl; + // Breakpoint 2 + // Put a breakpoint on the following line + else { + cout << "Adult" << endl; + } + return 0; +} \ No newline at end of file diff --git a/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.sln b/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.sln new file mode 100644 index 0000000..8fed5aa --- /dev/null +++ b/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32929.385 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CST116-Ch7-Debugging-Ahmed", "CST116-Ch7-Debugging-Ahmed.vcxproj", "{B0D44148-EC98-40C2-9B22-161D71C6254B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0D44148-EC98-40C2-9B22-161D71C6254B}.Debug|x64.ActiveCfg = Debug|x64 + {B0D44148-EC98-40C2-9B22-161D71C6254B}.Debug|x64.Build.0 = Debug|x64 + {B0D44148-EC98-40C2-9B22-161D71C6254B}.Debug|x86.ActiveCfg = Debug|Win32 + {B0D44148-EC98-40C2-9B22-161D71C6254B}.Debug|x86.Build.0 = Debug|Win32 + {B0D44148-EC98-40C2-9B22-161D71C6254B}.Release|x64.ActiveCfg = Release|x64 + {B0D44148-EC98-40C2-9B22-161D71C6254B}.Release|x64.Build.0 = Release|x64 + {B0D44148-EC98-40C2-9B22-161D71C6254B}.Release|x86.ActiveCfg = Release|Win32 + {B0D44148-EC98-40C2-9B22-161D71C6254B}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2D96A799-BBC3-412C-902D-33F28B360D22} + EndGlobalSection +EndGlobal diff --git a/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.txt b/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.txt new file mode 100644 index 0000000..94266c1 --- /dev/null +++ b/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.txt @@ -0,0 +1,24 @@ +FOR CHILD : + + Enter your age: 10 +Child + +C:\Users\macho\Source\Repos\cst116-ch7-debugging-M005A\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging.exe (process 18964) exited with code 0. + +FOR TEENAGER : +Enter your age: 15 +Teenager + +C:\Users\macho\Source\Repos\cst116-ch7-debugging-M005A\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging.exe (process 18828) exited with code 0. + +FOR ADULT : +Enter your age: 55 +Adult + +C:\Users\macho\Source\Repos\cst116-ch7-debugging-M005A\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging.exe (process 14928) exited with code 0. + +FOR SENIOR : +Enter your age: 65 +Senior + +C:\Users\macho\Source\Repos\cst116-ch7-debugging-M005A\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging.exe (process 5912) exited with code 0. \ No newline at end of file diff --git a/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.vcxproj b/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.vcxproj new file mode 100644 index 0000000..1816c2b --- /dev/null +++ b/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.vcxproj @@ -0,0 +1,141 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {b0d44148-ec98-40c2-9b22-161d71c6254b} + CST116Ch7Debugging + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.vcxproj.filters b/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.vcxproj.filters new file mode 100644 index 0000000..7670473 --- /dev/null +++ b/CST116-Ch7-Debugging-Ahmed/CST116-Ch7-Debugging-Ahmed.vcxproj.filters @@ -0,0 +1,32 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Source Files + + + + + Source Files + + + \ No newline at end of file diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging-Ahmed.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging-Ahmed.cpp deleted file mode 100644 index 9563dba..0000000 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging-Ahmed.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************** -* File: CST116-Ch7-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) When prompted, enter your age. -* 4) When the execution stops, add a watch on age and verify that -* the value in age is what you typed in. -* 5) Step over the if statement. -* 6) Why did the value in age change? -* In the if statement, the conditional was written as "age = 0" -* instead of "age == 1", thus the age is set to 1 everytime. -* 7) Fix the problem and repeat Steps 2 – 5 to verify the -* problem was corrected. -* 8) Stop debugging. -* -* Debugging Exercise 2 -* -* 1) Run to Breakpoint 1. -* 2) When prompted, enter the value 25 for your age. -* 3) Step over the if statement. Execution of the program should -* continue on the else if statement. -* 4) Verify that 25 is still stored in age. -* 5) Step over the else if. -* 6) Why is the program going to print "Teenager" for an age of 25? -* The else if statement was checking if the age was greater than -* or equal to 12 OR less than or equal to 19. Instead it should be -* checking if the age is between 12 AND 19 inclusively. -* 7) Fix the problem and repeat Steps 1 – 5 to verify the -* problem was corrected. -* 8) Stop debugging. -* 9) Remove Breakpoint1. -* -* Debugging Exercise 3 -* -* 1) Run the program without debugging. -* 2) When prompted, enter the value of 10 for your age. -* 3) Why does the program print both "Child" and "Adult"? -* There is a cout statement at the end of all the else if statements -* which is executing every time main is run. -* 4) Re-run the program this time with debugging and run to -* Breakpoint 2. -* 5) Why is the action with the else executing? -* The else statement has a semicolon at the end of it, so the statement -* is not included in the else statement and runs regardless of any conditions. -* Everytime main is executed, it will print adult at the end. -* 6) Fix the problem and re-run to verify the problem was corrected. -********************************************************************/ - -#include -using std::cout; -using std::endl; -using std::cin; - -int main() -{ - int age = 0; - - cout << "Enter your age: "; - cin >> age; - - // Breakpoint 1 - // Put a breakpoint on the following line - if (age == 1) - cout << "First Birthday" << endl; - else if (age >= 12 && age <= 19) - cout << "Teenager" << endl; - else if (age < 12) - cout << "Child" << endl; - else if (age > 62) - cout << "Senior" << endl; - // Breakpoint 2 - // Put a breakpoint on the following line - else { - cout << "Adult" << endl; - } - return 0; -} \ No newline at end of file diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging-Ahmed.txt b/CST116-Ch7-Debugging/CST116-Ch7-Debugging-Ahmed.txt deleted file mode 100644 index 94266c1..0000000 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging-Ahmed.txt +++ /dev/null @@ -1,24 +0,0 @@ -FOR CHILD : - - Enter your age: 10 -Child - -C:\Users\macho\Source\Repos\cst116-ch7-debugging-M005A\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging.exe (process 18964) exited with code 0. - -FOR TEENAGER : -Enter your age: 15 -Teenager - -C:\Users\macho\Source\Repos\cst116-ch7-debugging-M005A\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging.exe (process 18828) exited with code 0. - -FOR ADULT : -Enter your age: 55 -Adult - -C:\Users\macho\Source\Repos\cst116-ch7-debugging-M005A\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging.exe (process 14928) exited with code 0. - -FOR SENIOR : -Enter your age: 65 -Senior - -C:\Users\macho\Source\Repos\cst116-ch7-debugging-M005A\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging.exe (process 5912) exited with code 0. \ No newline at end of file diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.sln b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.sln deleted file mode 100644 index fef98b1..0000000 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.3.32804.467 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CST116-Ch7-Debugging", "CST116-Ch7-Debugging.vcxproj", "{B0D44148-EC98-40C2-9B22-161D71C6254B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B0D44148-EC98-40C2-9B22-161D71C6254B}.Debug|x64.ActiveCfg = Debug|x64 - {B0D44148-EC98-40C2-9B22-161D71C6254B}.Debug|x64.Build.0 = Debug|x64 - {B0D44148-EC98-40C2-9B22-161D71C6254B}.Debug|x86.ActiveCfg = Debug|Win32 - {B0D44148-EC98-40C2-9B22-161D71C6254B}.Debug|x86.Build.0 = Debug|Win32 - {B0D44148-EC98-40C2-9B22-161D71C6254B}.Release|x64.ActiveCfg = Release|x64 - {B0D44148-EC98-40C2-9B22-161D71C6254B}.Release|x64.Build.0 = Release|x64 - {B0D44148-EC98-40C2-9B22-161D71C6254B}.Release|x86.ActiveCfg = Release|Win32 - {B0D44148-EC98-40C2-9B22-161D71C6254B}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B1BAFB67-0814-461E-B8A6-F98D952B9DA1} - EndGlobalSection -EndGlobal diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj deleted file mode 100644 index f9cc4e8..0000000 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj +++ /dev/null @@ -1,138 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {b0d44148-ec98-40c2-9b22-161d71c6254b} - CST116Ch7Debugging - 10.0 - - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - \ No newline at end of file diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.filters b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.filters deleted file mode 100644 index 6d3c958..0000000 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.filters +++ /dev/null @@ -1,27 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - Source Files - - - \ No newline at end of file diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.user b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.user deleted file mode 100644 index 0f14913..0000000 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file -- cgit v1.2.3