Course Solutions Uncategorized (Solved) : 5 Pts Following C Program Output Include Int X 2 Void F Std Cout X N Void G Int X 5 F Std Q33064932 . . . .

(Solved) : 5 Pts Following C Program Output Include Int X 2 Void F Std Cout X N Void G Int X 5 F Std Q33064932 . . . .

 

(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. . . . .

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post