computer science programming

vazquez1012
For this assignment, prepare two related programs as .cpp files and submit them in a single zipped file.

Program #1 Instructions:

  1. Write a simple program to validate passing by value and passing by reference.
  2. Initialize a variable and display its value.
  3. Pass the variable by value to a function. Change the value of the variable in the pass by value function. Display the modified value inside the function.
  4. After the pass by value function returned, display the value again in the main function.
  5. Pass the same variable, now passing by reference to another function. Change the value of the variable in the pass by reference function. Display the modified value inside the function.
  6. After the pass by reference function returned, display the value again in the main function.
  7. See the sample code below for an example of how your program output should look:

Variable name has the value "Barry"

calling pass by value
Parameter now has the value "Thomas"

pass by value returned
Variable name has the value "Barry"

calling pass by references
Parameter now has the value "James"

call by reference returned
Variable name has the value "James"

  1. Name the project: PassingByValueReference.cpp

Program #2 Instructions:

  1. Write another simple Address program to print the value of the memory addresses of the variables listed below:
    • a char
    • a string
    • an array of integers
    • an integer
    • a double
  1. See the sample code below for an example of how your program output should look:

Integer has memory address 0x434232
String has memory address 0x434234
Array has memory address 0x434320
Array[1] has memory address 0x434322
Array[2] has memory address 0x434324
Array[3] has memory address 0x434326
etc...
etc...

  1. Name the project: Address.cpp

Place your two .cpp files in a single zipped folder.

    • 9 years ago
    • 5
    Answer(1)

    Purchase the answer to view it

    NOT RATED
    • cpp_files.rar
    • sample_outputs.docx
    Bids(1)