Complete the tables that follow to describe the memory addresses and values of each variable when the last statement in the ChangePasscode function is performed (right before the function exits). Note: Operating systems may use different rules for assigning memory addresses. For this worksheet let us assume that the compiler will use up the greater memory address first (e.g., if 0x7ffd151a1d58 and 0x7ffd151a1d5c are available, it will initialize variables in 0x7ffd151a1d5c first). #include   // Changes the passcode to new_passcode if  // verify_passcode matches the old passcode. bool ChangePasscode(int& passcode, int verify_passcode,                     int new_passcode) {  if (verify_passcode == passcode) {    passcode = new_passcode;    return true;  } else {    return false;  } }   int main() {  int passcode = 112233;  int verify_passcode = 0;  int new_passcode = 0;  std::cout << "Please enter old passcode: ";  std::cin >> verify_passcode; // user enters 112233  std::cout << "Please enter new passcode: ";  std::cin >> new_passcode;    // user enters 456789    bool changed_passcode = ChangePasscode(passcode,                                         verify_passcode,                                         new_passcode);  if (changed_passcode) {    std::cout << "Passcode changed.";  } else {    std::cout << "Passcode remains the same.\n";  }  return 0; } Output: Please enter old passcode: 112233 Please enter new passcode: 456789 Passcode changed

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Complete the tables that follow to describe the memory addresses and values of each variable when the last statement in the ChangePasscode function is performed (right before the function exits). Note: Operating systems may use different rules for assigning memory addresses. For this worksheet let us assume that the compiler will use up the greater memory address first (e.g., if 0x7ffd151a1d58 and 0x7ffd151a1d5c are available, it will initialize variables in 0x7ffd151a1d5c first).

#include <iostream>

 

// Changes the passcode to new_passcode if 

// verify_passcode matches the old passcode.

bool ChangePasscode(int& passcode, int verify_passcode,
                    int new_passcode) {

 if (verify_passcode == passcode) {

   passcode = new_passcode;

   return true;

 } else {

   return false;

 }

}

 

int main() {

 int passcode = 112233;

 int verify_passcode = 0;

 int new_passcode = 0;

 std::cout << "Please enter old passcode: ";

 std::cin >> verify_passcode; // user enters 112233

 std::cout << "Please enter new passcode: ";

 std::cin >> new_passcode;    // user enters 456789

 

 bool changed_passcode = ChangePasscode(passcode,

                                        verify_passcode,

                                        new_passcode);

 if (changed_passcode) {

   std::cout << "Passcode changed.";

 } else {

   std::cout << "Passcode remains the same.\n";

 }

 return 0;

}

Output:

Please enter old passcode: 112233

Please enter new passcode: 456789

Passcode changed

Symbol Table (complete the memory addresses by providing their last 2 digits)
Variable Name Scope
passcode
main()
verify_passcode main()
new_passcode main()
passcode
Type
int
int
int
Ox7ffd151a1d54
Change Passcode() int
0x7ffd151a1d____
verify_passcode
Change Passcode() int
Ox7ffd151a1d_____
new_passcode Change Passcode() int
Ox7ffd151a1d_
Note: You only need to fill in the last 2 digits of the address. The rest has been provided for you.
Memory address*
Ox7ffd151a1d5c
Ox7ffd151a1d58
Transcribed Image Text:Symbol Table (complete the memory addresses by providing their last 2 digits) Variable Name Scope passcode main() verify_passcode main() new_passcode main() passcode Type int int int Ox7ffd151a1d54 Change Passcode() int 0x7ffd151a1d____ verify_passcode Change Passcode() int Ox7ffd151a1d_____ new_passcode Change Passcode() int Ox7ffd151a1d_ Note: You only need to fill in the last 2 digits of the address. The rest has been provided for you. Memory address* Ox7ffd151a1d5c Ox7ffd151a1d58
Memory Visualization (provide the value stored in the corresponding memory address)
0x7ffd151a1d0c
Ox7ffd151a1d10
Ox7ffd151a1d14
Ox7ffd151a1d54
0x7ffd151a1d58
0x7ffd151a1d5c
Value
456789
112233
112233
ChangePasscode()
main()
Transcribed Image Text:Memory Visualization (provide the value stored in the corresponding memory address) 0x7ffd151a1d0c Ox7ffd151a1d10 Ox7ffd151a1d14 Ox7ffd151a1d54 0x7ffd151a1d58 0x7ffd151a1d5c Value 456789 112233 112233 ChangePasscode() main()
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY