Question: I need some help with my c++ homework Use C++ code below 1.) Function TestLocals defines a local variable, count, and initializes it to 1.

I need some help with my c++ homework

Use C++ code below

1.) Function TestLocals defines a local variable, count, and initializes it to 1. The contents of count are incremented and sent to the output stream. Write this code and run program Differences. Record your output.

2.) Change function TestLocals so that the local variable count is a static variable. Re-run your program and record your output.

3.) Explain the difference between automatic and static variables.

Given code (C++):

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Program Differences is for investigating the differences // between automatic and static variables.

#include using namespace std;

void TestLocals();

int main () { TestLocals (); TestLocals (); TestLocals (); return 0; }

// ***************************************

void TestLocals() { /* TO BE FILLED IN */ }

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 Databases Questions!