Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE C++ ONLY! DUE TODAY PLEASE!! Question 1: NO TEST PLAN IS NEEDED FOR THIS QUESTION Watch this short debugging video: https://www.youtube.com/watch?v=eEJ5xKO7c3o We havent yet

USE C++ ONLY! DUE TODAY PLEASE!!

Question 1: NO TEST PLAN IS NEEDED FOR THIS QUESTION Watch this short debugging video: https://www.youtube.com/watch?v=eEJ5xKO7c3o We havent yet learned all programming concepts discussed in the video but the techniques demonstrated are still useful. The video includes showing how to activate a breakpoint at a specific value rather than every occurrence. In addition, it is possible to jump ahead to a specific value, skipping all values between current value and desired value. This could be desirable if a lot of calculations or time are expended in order to proceed from the current value to the desired test value. To do a jump, once the program has paused due to a breakpoint activating, simply click on the value for the variable you wish to monitor (in the locals window) and change the value by typing a new value over it. Then, hit F5 or F10 to continue debugging. The program will pause when that value is reached. Make sure line numbers are turned on in your environment: 1. In the menu bar, choose Tools > Options. Expand the Text Editor node, and then select either the language you're using or All Languages to turn on line numbers in all languages. (Or, type line number in the search box and choose Turn line numbers on or off from the results) Line numbers have no affect on your programs. 2. Select the Line numbers checkbox then click OK. Try debugging, using the below code to play with along with the instructions that follow #include #include using namespace std; int main() { int cnt = 0, i, j, width; char userInput = '#'; for (int height = 1; height < 1000; height++) { width = height; cout << " Doing triangle " << height << endl; for (i = 0; i < height; ++i) //line 12 { cnt += 2; for (j = 0; j < width; ++j) //line 15 cout << userInput; cout << endl; width--; }

} system("pause"); return 0; } Put a breakpoint at line 12 (see code comment). Right-click on the breakpoint and select Conditions. First drop- down, select hit-count; second, select =; third, enter 5, and Hit F5. Do not close the pop-up window. Take a snippet of the Output window and the Locals window showing 6 variables, their values, and data types, and include both snippets in your report. What mathematical relationship do you see between variables i, height, and cnt? Now, edit variable height in locals window (by right-clicking on variable and selecting edit value) and change the value to 10 then hit Tab. Change Hit Count from 5 to 7 and hit F5. Look at Locals window. Does your relationship still hold? This demonstrates the danger of changing one variable without considering the consequences to other variables. Variable cnt is not reset inside the loop so its value is no longer accurate. All other variables are reset so they are fine. Take another snippet of your output window and include in your report. Close pop-up window Breakpoint Settings. Put another breakpoint on line 15 (see code comment). Hit F10 (executes one line at a time) a couple times to watch the debugger in action, paying attention to what the line of code should be doing and how variables are actually changed. Remove the breakpoint at line 15. Edit the value of variable height to a large number less than 1000 (such as 678) and hit F5. Stop the program when you are tired of watching it.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions

Question

Discuss communication challenges in a global environment.

Answered: 1 week ago