Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Step 5: Execute the following version of the program from step 1and explain the

ID: 3639194 • Letter: S

Question

Step 5: Execute the following version of the program from step 1and explain the results. In particular, note that variables named x are declared at various locations. What can you conclude about a local variable residing within the scope of a global variable of the same name?

#include <iostream>
using namespace std;

char x;

void fun3();
void fun4();

int main() {
x = 'Z';
cout << "x = " << x << endl;
fun3();
cout << "x = " << x << endl;
fun4();
cout << "x = " << x <<endl;

return 0;
}

void fun3() {
x = 'H';
cout << x << "ey Dickinson is in North Dakota not Texas! ";
}

void fun4() {
char x;
x = 'Y';
cout << x << "ou bet it's cold! ";
}

Explanation / Answer

x = Z /// u intialzed with zHey Dickinson is in North Dakota not Texas!x = H // since x is global variable fun3 updated that variable.You bet it's cold!x = H // here again x is local t ofunc4 thats y it is not updated

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote