(5 pts) What does the following C++ program output?
#include <iostream>int x = 2;void f() { std::cout << x << ‘n’; }void g() { int x = 5; f(); std::cout << x << ‘n’; }int main() { g(); std::cout << x << ‘n’;}
Verify that the answer you obtained is the same that would beinferred from apply the rules of static scoping. If C++ useddynamic scoping, what would the output have been? (Note: you mayneed to read about static vs. dynamic scoping.)
Expert Answer
An answer will be send to you shortly. . . . .