To do this problem you will need to dynamically create a


This problem is designed to make sure you can write a program that uses the data passed into it such that the caller's data has been updated. We will use a struct, since it is the most important form of information used in Data Structures.

The Solution / Test Requirements

To do this problem, you will need to dynamically create a struct that contains 4 integer fields. The fields should be called X, Y, TheSum and TheProduct.

One function is needed to augment your test main. It is called Compute.

Compute is a function that receives the struct holding the data (X, Y, TheSum and TheProduct). How should Compute receive the struct such that the caller will see a sum of X+Y and a product of X*Y? What happens inside Compute?

Your Test Main must: 1. Declare the struct using a typedef.

2. Dynamically allocate the struct using the typedef and fill it with the following data:

a. X = 20

b. Y = -7

c. TheSum = 0

d. TheProduct = 0

3. Print out the four fields in the struct.

4. Call Compute passing the struct such that the fields in the struct can be updated

5. Print out the four fields in the struct on return from the function.

6. Free the memory that was dynamically allocated.

For your convenience, here is an output of my program:

Before call to Compute, X= 20, Y= -7, TheSum=0 and TheProduct = 0

After call to Compute, X= 20, Y= -7, TheSum=13 and TheProduct = -140

Process returned 0 (0x0) execution time : 0.016 s

Press any key to continue.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: To do this problem you will need to dynamically create a
Reference No:- TGS02898435

Expected delivery within 24 Hours