Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE READ ALL INSTRUCTION CAREFULLY!! 30/38 Exercise F18 Given the following structure: struct Demo int first, second; Do the following: a. Write a function readDemo)

PLEASE READ ALL INSTRUCTION CAREFULLY!!

image text in transcribedimage text in transcribed

30/38 Exercise F18 Given the following structure: struct Demo int first, second; Do the following: a. Write a function readDemo) that reads the values for the member variables of a structure Demo and returns that structure. b. Write a code segment to define a Demo structure variable named temp and to read values into its members variables by calling function readDemo). a. Write a function addDemo) that receives as arguments two Demo structures as value parameters, and then builds and returns another Demo structure such that the values of its members variables are the sums of the values of the corresponding member variables of the structures received as arguments. 2011 Gilbert Ndjatou Page 198 b. Write a code segment to create the Demo structure variable demo such that the values of its member variables are the sums of the values of the corresponding member variables of the Demo structures demol (with values 5 and 7 respectively) and demo 2 (with values 10 and 15 respectively). The sums of the values of the member variables of the structure variables are computed by calling the function addDemo) defined above. a. Write a void function updateDemol() that has a Demo structure as a reference parameter. This function adds 10 to the value of the first member variable of the structure, and subtracts 5 from the value of its second member variable. b. Write a code segment to define a Demo structure variable named temp with its member variables initialized with 6 and 7 respectively. It then adds 10 to the value of its first member variable and subtracts 5 from the value of its second member variable by calling function updaDemol(). b. Write a code segment to create the Demo structure variable demoR such that the values of its member variables are the sums of the values of the corresponding member variables of the Demo structures demol (with values 5 and 7 respectively) and demo2 (with values 10 and 15 respectively). The sums of the values of the member variables of the structure variables are computed by calling the function addDemo) defined above. a. Write a void function update Demol() that has a Demo structure as a reference parameter. This function adds 10 to the value of the first member variable of the structure, and subtracts 5 from the value of its second member variable. b. Write a code segment to define a Demo structure variable named temp with its member variables initialized with 6 and 7 respectively. It then adds 10 to the value of its first member variable and subtracts 5 from the value of its second member variable by calling function updaDemol(). Programs with two or more Source Modules The functions that make up a C++ program may be stored in one or more files called source files. A global variable defined in one source file may be accessed in another source file only if it has been declared (but not defined) in that source. You declare (without defining) a global variable by preceding its declaration statement with the keyword extern. A new memory location is not created for a variable whose declaration statement is preceded with the keyword extern. The prototype of a function defined in another source module may also be preceded with the keyword extern, but this is not necessary

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

Explain the factors that determine the degree of decentralisation

Answered: 1 week ago

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago

Question

6. Are my sources reliable?

Answered: 1 week ago

Question

5. Are my sources compelling?

Answered: 1 week ago