ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 2 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 11 May 2017 My Price 9.00

void process(int vnum, int & rnum1, int & rnum2)

Exercise F5

Assume given the following definition of function process:

void process(int vnum, int & rnum1, int & rnum2)

{

vnum = vnum + 5;

rnum1 = rnum1 + 10;

rnum2 = vnum + rnum1;

}

And that local variables are defined in function main as follows:

int num1 = 6, num2 = 9, num3 = 12;

Indicate whether each of the following calls of function process is valid or invalid. Also give the reason why a call is invalid.

a. process( 15, num2, num3 );

b. process( 21, num1 + 3, num2 );

c. process( num3, num1, num2 );

d. process( num1, 10, num3 );

e. process( 3, num1, 25 );

f. process( num1, num2, num3 + 4);

g. process( num2, num1 );

h. process( num1 + 3, num2, num3);

i. process( 5, num3 );

j. process( num1, num1, num3 );

_________________________________________________________________

Exercise F6
Assume given the following definition of function process:
void process(int vnum, int & rnum1, int & rnum2)
{
vnum = vnum + 5;
rnum1 = rnum1 + 10;
rnum2 = vnum + rnum1;
}
And that local variables are defined in function main as follows:
int num1 = 6, num2 = 9, num3 = 12;
1. For each of the following calls of function process, show the body of function process in the way it is executed after the call.
2. For each of the following calls, execute function process and display the corresponding output.
a. process( 15, num2, num3 );
cout << endl << “num1=” << num1 << “num2=” << num2 << “num3=” << num3;
b. process( num1, num2, num3 );
cout << endl << “num1=” << num1 << “num2=” << num2 << “num3=” << num3;
c. process( num1 + 3, num2, num3);
cout << endl << “num1=” << num1 << “num2=” << num2 << “num3=” << num3;

 

_____________________________________________________

Exercise F7

Assume given the following definition of function computeAreaPeri2 that computes the area and the perimeter of a rectangle given its length and width:
void computeAreaPeri2( double len, double wid, double &ar, double &peri )
{
ar = len * wid;
peri = 2 * ( len + wid );
}
a. Write the sequence of statements to compute and print the area and the perimeter of a rectangle with length 70 and width 45.
b. Write the sequence of statements to read the length and the width of a rectangle and to compute and print its area and perimeter.

 

©2011 Gilbert NdjatouPage 169FUNCTIONSIn addition to functionmain, a program source module may contain one or more other functions.The execution of the program always starts with functionmain.The statements of a function (other than functionmain) are executed only if that function is called infunctionmainor any other function that is called in functionmain.After the statements of a function are executed, the next statement to be executed is the one thatfollows the statement in which that function is called.ExampleThe statements of the program in figure F1 are executed in the following order: 23, 24, 26, 15, 16,27, 28, 31, 32, 34, 15, 16, 35, 36, and 37.There are two types of functions in the C/C++ programming language:Functions that do not return a value:voidfunctions, andFunctions that return a value.You can also write a function with or withoutparameters:An example of avoidfunction without parameters is provided in figure F1, line 13 to line 17.An example of avoidfunction with parameters is provided in figure F2, line 8 to line 12.Defining and Calling avoidFunction without ParametersYou define avoidfunction without parameters as follows:void<function-name>( ){<Body-of-the-function>}<function-name>is thename of the functionvoid<function-name>( )is thefunction header.It may also be specified as follows:void<function-name>( void )<Body-of-the-function>is thebody of the function:It consists of one or more statements that areexecuted each time the function iscalled.

Attachments:

Answers

(11)
Status NEW Posted 11 May 2017 01:05 AM My Price 9.00

-----------

Attachments

file 1494465075-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)