Question: Explain the relationship between variable and memory (5 points) Contrast local variable vs global variable (5 points) For the code before, find the local and

Explain the relationship between variable and memory (5 points)

Contrast local variable vs global variable (5 points)

For the code before, find the local and global variable(s) and give the program output (10 points)

#include using namespace std; int g; int main () { int a, b; // actual initialization a = 10; b = 20; g = a + b; cout << g; return 0; }

Define forward declaration (5 points)

Add a function prototype to the code below and explain why it is needed (10 points)

#include

int main()

{

std::cout << "The sum of 3 and 4 is: " << add(3, 4) << std::endl;

return 0;

}

int add(int x, int y)

{

return x + y;

}

7.Contrast passing by value and by reference (5 points)

Read the code below and give program output and explain (10 points)

#include using namespace std; void duplicate (int& a, int& b, int& c) { a*=2; b*=2; c*=2; } int main () { int x=1, y=3, z=7; duplicate (x, y, z); cout << "x=" << x << ", y=" << y << ", z=" << z; return 0; }

Define array and explain how it is storage is related to memory (5 points)

Identify the pointer below and draw a figure that illustrate the relationship among the variables below (10 points)

myvar = 25; foo = &myvar; bar = myvar;

Read the code below on struct below and explain: (5 points)

struct product { int weight; double price; } ; product apple; product banana, melon;

Define enumerated types and declare a variable called enum_month which contains the names from three primary colors (5 points)

Write a C++ program that compare two string whether they are equal or not (10 points).

Explain whats const double pi = 3.14159; and const char newline = ' '; in the code below (5 points)

#include using namespace std; const double pi = 3.14159; const char newline = ' '; int main () { double r=5.0; // radius double circle; circle = 2 * pi * r; cout << circle; cout << newline; }

Read the code below and give program output and explain the each line of the code in the main function (10 points)

#include #include using namespace std; int main () { ofstream myfile; myfile.open ("example.txt"); myfile << "Writing this to a file. "; myfile.close(); return 0; }

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!