Create a struct that contains four integer fields

Assignment Help C/C++ Programming
Reference no: EM132104980

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.

Reference no: EM132104980

Questions Cloud

Income statement for september : The company expects to sell $560 units in September. Example of an income statement for September using contribution margin format.
Implement the method and constructor with added requirement : addAll( ) : adjust the type of the parameter, it is an ArrayBag with the same generic type parameter; the method checks.
Explore the issue of truthfulness in the stable matching : Explore the issue of truthfulness in the Stable Matching Problem and specifically in the Gale-Shapley algorithm.
Determine the big-oh for the performance of your algorithm : The numbers are read by the program from a file. The numbers in the file are not necessarily sorted.
Create a struct that contains four integer fields : 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.
Show the tables in 1nf and 2nf that are created in process : Use the process of normalization to transform the table below into 3NF. Show the tables in 1NF and 2NF that are created in the process.
Concern to entrepreneurs : Why should ethics or social responsibility be of concern to entrepreneurs (how an establishment reacts to the demands of its stakeholders)?
Growth strategy of starbucks : The strategy was proposed after following a defined process of analysis and drawing inference as all the study and their result is also included in the proposal
Calculate the company operating cycle : Assume a 365-day year. how do I calculate the company's operating cycle and cash conversion cycle?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd