I need to build a c++ program with the instructions on the document. The libraries to be used should be "splashkit.h", "", "iostream". I have also attached the headstart. Thanks.

1 answer below »
I need to build a c++ program with the instructions on the document. The libraries to be used should be "splashkit.h", "", "iostream". I have also attached the headstart. Thanks.


While the focus of this task is on the declaration and usage of pointers in data manipulation, remember to deliver your task in a good quality with proper coding convention and practice under considerations of the following but not limited to: comments, indentation, snake_case, and meaningful identifiers whenever appropriate. SIT102 Introduction to Programming Pass Task 9.2: Data Pass by Pointers We are approaching to the end of the trimester. This 9.2P TASK due and MILESTONE due are NOT able to be postponed beyond the trimester. We highly encourage you submit your 9.2P as soon as you could such that there is sufficient time for both the teaching team reviewing your on-time submission and you fixing your work (if necessary) by the MILESTONE due (See 9.MP task for details) Please note: If you need to apply an extension for 9.2P, OnTrack will only auto-grant you a few days up to 23 May 2022. Please also note there is no room for any extension on 9.MP (MILESTONE). Overview of 9.2P task Pointers are one of efficient building blocks in a C++ program to support its dynamic allocation routines. After discussions in this week’s topics about fundamental of pointers including its nature in terms of the data fields, data referencing and dereferencing rationales and operations, as well as data access and pointers challenges, this task enables you to apply, demonstrate and reinforce your understanding and associated programming skills on pointers usage and data manipulation by various forms of illustrations and works including codes, quick answers, screenshots, and drawings. Submission Details Follow the instructions on the following pages, weekly videos and class contents to create a C++ program to explore the usage of pointers and passing data by pointer. Submit the following files to OnTrack. • Your answers to the associated questions (9.2P Answers.docx) in PDF • Your C++ program code with your answer to both part A and part B Instructions – Resources 1. Obtain the given code snippet to start with in Resources.zip. Note: this task requires you to demonstrate your understanding on the variables’ nature and their relationship so that they are not named based on their meanings in the given code snippet. However, maintain good coding convention whenever appropriate in your new implementation. 2. The given instructions and implementation in the code snippet demonstrates how data value and address of ordinary variables (i.e. variables d, and s) in different types are obtained and printed onto the Terminal using :: write/write_line. Fig. 1 shows you the sample execution outcome of the given start-up code snippet. They are the quick recap of active class – week 9 contents for you to begin with. Fig. 1: Execution outcome of the given start-up code snippet. 3. For you starting off Part B, you are also provided the implementation and programming logic for void swap_pass_by_value(string s, string name) where it reminds you how pass-by-value is applied and provides you with a simple swap (two values) mechanism in the code snippet. Note that swap_pass_by_value(…) is called at the end of pointer_var_info(). That is the entry point for your Part B with the objective of exploring pass-by-value and pass-by-pointer. 4. Get the questions (in 9.2P Answers.docx) in Resources.zip along with you. Following the instructions, you would showcase some of your workout there as parts of your submission. Instructions – Your tasks Part A: 1. In order to complete the table in 9.2P Answers.docx, you are required to a. demonstrate the correct usage of the declared/defined pointer variables in C++ (i.e. variables x and z). Also refer to Fig. 1 and the README code comments in the start-up snippet. b. obtain the requested information from the pointer variables i. Memory location of the variable ii. Value stored in the corresponding variable iii. Variable name c. show all of the above information onto the Terminal (You may choose to make use of either ::cout or :: write for displaying information to the Terminal). 2. Besides your code implementation, you are also required to show the execution Terminal output of your program and answer all the questions in Resources.zip. Part B: 1. In the start-up code snippet, variables string s, *z, and name have been declared and defined for you in pointer_var_info(). You are now required to modify the code to ask the user to input a name and save it in string name, as a real-time data input collection instead of having a pre-defined value for string name. 2. Then declare a new pointer variable that points to (is referencing to) string name. Make sure your implementation works properly. 3. Keep implementing your program to accomplish the following: a. Demonstrate that your program is capable of swapping two input values by using pass-by- pointer approach under the following declaration  void swap_pass_by_pointer(string *z, string *) b. The same actions as in the given swap_pass_by_value(…) as i. 1. Print the passed in values to Terminal ii. 2. Apply a simple swap mechanism iii. 3. Print the updated values to the Terminal just after the swap should be conducted but the data should be passed in by pointers in your implementation. c. For each declared variable, verify how their values are stored respectively inside and out of the swap procedures. You should obtain similar outcomes as shown in Fig. 2 with your own values. Since we are implementing them as procedures, as you can see, the pass-by-value approach does not work. In contrast, the pass-by-pointer approach works as expected. Fig. 2: Expected outcomes of values swapping by pass-by-value and pass-by-pointer. 4. After your implementation, go back to 9.2P Answers.docx, provide execution Terminal output of your program, and answer all the questions there to comment different data passing approaches. 5. Make sure you have completed all task requirements. Save your 9.2P Answers.docx as a PDF. Submit it together with your part A and part B code implementation in one single .cpp to OnTrack. That’s all for the instructions. Good luck to your task! Task Discussion You tutor may ask you the following question(s) via OnTrack. You have to address them to demonstrate your understanding of the concepts covered. • Explain how pass-by-value, pass-by-reference, and pass-by-pointer work. • Discuss the pros and cons of adopting the above three data-passing approaches. • How would pointers help in dynamic memory allocation for data storage? Overview of 9.2P task Submission Details Instructions – Resources Instructions – Your tasks Task Discussion SIT102 – Introduction to Programming Answers for 9.2P Data Pass by Pointers Student Name: Student ID: Based on the given start-up code snippet in Resources.zip and your own implementation addressing the task requirements, provide your answers to the following questions. Part A: 1. There are 4 variables declared in the given start-up code snippet. Complete the following table with the correct memory addresses and the stored value accordingly for each variable. You have to add in your implementation to the given code in order to obtain all the required information for those pointer variables (i.e. variables x and z). Bear in mind, as discussed in the classes that those memory addresses are different from any illustration shown in this tasksheet and may also be different from your friends’ workout. Memory location of the variable (You may have different value, replace all contents here by your own value.) Based on the given code, value stored in the variable Variable name 27051164584 (Based on execution outcome shown in the tasksheet) 7.99 d SIT102 s x z 2. Provide the execution output of your modified program by a screenshot of your Terminal, which could fully verify your answers provided in the above question. 3. Depict the relationship of the above-mentioned FOUR variables - d, s, x, and z by a drawing in the style of hand execution that has been utilised since week 2 and week 9 classes. Note 1: Make good use of an arrow connecting memory locations (depicted by two boxes as shown) to illustrate the referencing/dereferencing direction. E.g. variable a is pointing to a memory location which stores the current value for variable b as shown below. This kind of drawing would be used by you to effectively demonstrate your understanding about relationship between variables and memory locations in Part B. Variable a Variable b Value stored in b Value stored in a Note 2: Make sure you have filled in correct values/names in your drawing based on the given code. Part B: 4. Provide the execution output of your Part B workout by a screenshot of your Terminal which could throw a scene for your following answers. 5. Depict the relationship of the following THREE variables - name, s, and temp by a hand execution drawing for the pass-by-value scenario. Show how the values are declared/defined, processed/changed from the beginning of the program execution to the end of this swap process. 6. Depict the relationship of the following FIVE variables - name, z, s, temp, and your newly declared pointer by a hand execution drawing for the pass-by-pointer scenario. Show how the values are declared/defined, processed/changed from the beginning of the program execution of this swap process.
Answered 21 days AfterMay 18, 2022

Answer To: I need to build a c++ program with the instructions on the document. The libraries to be used should...

Nimesh answered on Jun 09 2022
102 Votes
SIT102 – Introduction to Programming
Answers for 9.2P Data Pass by Pointers

Student Name:
Student ID:


Based on the given start-up code snippet in Resources.zip and your own implementation
addressing the task requirements, provide your answers to the following questions.

Part A:

1. There are 4 variables declared in the given start-up code snippet. Complete the following
table with the correct memory addresses and the stored value accordingly for each
variable. You have to add in your implementation to the given code in order to obtain all
the required information for those pointer variables (i.e. variables x and z).
Bear in mind, as discussed in the classes that those memory addresses are different from any
illustration shown in this tasksheet and may also be different from your friends’ workout.
Memory location of the variable
(You may have different value, replace all
contents here by your own value.)
Based on the given code,
value stored in the variable
Variable
name
004FFBB4 7.99 d
004FFB84 SIT102 s
004FFBA8 004FFBB4 x
004FFB78 004FFB84 z


2. Provide the execution output of your modified program by a screenshot of...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here