C++ Memory Allocation: 1) Write a C++ program that allocates static, stack, & heap memory. Your program
Question:
1)Write a C++ program that allocates static, stack, & heap memory. Your program does not need to do anything else.Indicate via commentswhere memory for at least one variable in each memory area is allocated.
a) Write code that allocates static memory (only include one declaration):
b) Writecode that allocates stack memory (only include one declaration):
c) Writecode that allocates heap memory (only include one declaration):
2)
1. Edit the C++ program below to include a pointer and a reference to num. Print the number using both the pointer and the reference.
#include
using namespace std;
int main()
{
int num = 10;
cout
return 0;
}
a) Writecode that declares a pointer to num:
b) Writecode that declares a reference to num:
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please show the code and explain in comments! Show the output as well thank you