Question: using namespace std void fun ( ) ; int main ( ) { int var = 5 ; / / local variable in main (

using namespace std void fun (); int main(){ int var =5; // local variable in main() cout <<"In main() var is: "<< var <<"
"; func(); cout << "Back in main() var is: "<< var <<"
"{ cout <<"In main() in a new scope var is: "<< var <<"
"; cout << "Creating new var in new scope.
"; int var =10; // variable in new scope, hides other variable named var cout <<"In main() in a new scope var is: "<< var <<"
"; } cout <<"At end of main() var created in new scope no longer exists.
"; cout <<"At end of main() var is: "<< var <<"
"; return 0; void func(){ int var =-5; // local variable in func() cout <<"In func() var is: "<< var <<"
"; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!