Question
This the code #include #include using namespace std; void pr_message(string s) { cout < < s < < endl; } int main() { int x
This the code
#include
void pr_message(string s) { cout << s << endl; }
int main() { int x = 1, y = 1; pr_message("Hello world!"); --x; y = x; pr_message("Hmm, what to do next?"); // Later on, un-comment out the following line, run it without // the debugger, and then choose to debug when it crashes. // A new VC++ debugger sessions starts. x = y / x; // divide by zero run-time error! pr_message("Ooh, that was close!"); x = 7; pr_message("OK, let's quit."); return 0; }
Directions: Copy the program "msvs_exp.cpp" into Microsoft Visual Studios. Then follow the steps below and answer the following questions.
Question 1: Place a breakpoint at the line "int x = 1, y = 1;" and run the program using Debug, Start Debugging. The program stops at the first breakpoint. What are the values of x and y at this point in the program?
Question 2: Use the Step Over command once. What now are the values of x and y at this point in the program?
Question 3: In your own words, explain why the change in the values of x and y that occurred in Step 2 was not visible at the breakpoint in Step 1.
Question 4: The yellow arrow should be pointing to the line "pr_message("Hello world!");". Use the Step Into command to enter this function. Explain what you see.
Question 5: Now use the Step Out command to return to "pr_message("Hello world!");". What is the command you used for this action?
Question 6: Now in the main function, place a breakpoint on the line "x = y / x;". Keep an eye on the window as you continously use the Step Over command until you reach this breakpoint. What line in the program sets the denominator to cause the divide-by-zero error?
Question 7: Based on your answer in Question 6, correct the code to allow the program to run to completion.
PLEASE THIS IS THE 3RD time I post this ONLY QUESTIONS 1 THROUGH 7 is what I need to be answered
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started