1 Given the function heading void GetNums int howMany float

1.      Given the function heading

void GetNums( int howMany,
                          float& alpha,
                          float& beta )

which of the following is a valid function prototype for GetNums?

a.

void GetNums( int howMany, float& alpha, float& beta );

b.

void GetNums( int, float&, float& );

c.

int GetNums( int, float&, float& );

d.

a and b above

e.

a, b, and c above

3 points   

QUESTION 7

1.      A function SomeFunc has two formal parameters, alpha and beta, of type int. The data flow for alpha is one-way, into the function. The data flow for beta is two-way, into and out of the function. What is the most appropriate function heading for SomeFunc?

a.

void SomeFunc( int alpha, int beta )

b.

void SomeFunc( int& alpha, int beta )

c.

void SomeFunc( int alpha, int& beta )

d.

void SomeFunc( int& alpha, int& beta )

3 points   

QUESTION 8

1.      Given the function definition

viod Twist( int a,
                   int& b )

{
        int c;

        c = a + 2;
        a = a * 3;
        b = c + a;

}

what is the output of the following code fragment that involes Twist? (All variables are of type int.)

r = 1;
s = 2;
t = 3;
Twist(t, s);
cout << r << \' \' << s << \' \' << t << endl;

a.

1 14 3

b.

1 10 3

c.

5 14 3

d.

1 14 9

e.

none of the above

5 points   

QUESTION 9

1.      Which of the following statements about value parameters is true?

a.

The actual parameter is never modified by execution of the called function.

b.

The formal parameter is never modified by execution of the called function.

c.

The actual parameter must be a variable.

d.

The actual parameter cannot have a Boolean value.

e.

b and c above

3 points   

QUESTION 10

1.      Which of the following statements about reference parameters is true?

a.

The actual parameter can be modified by execution of the called function.

b.

The formal parameter can be modified by execution of the called function.

c.

The actual parameter must be a variable.

d.

The actual parameter cannot have a Boolean value.

e.

a, b and c above

a.

void GetNums( int howMany, float& alpha, float& beta );

b.

void GetNums( int, float&, float& );

c.

int GetNums( int, float&, float& );

d.

a and b above

e.

a, b, and c above

Solution

Question 1:
a.void GetNums( int howMany, float& alpha, float& beta );

Question 2:
c.void SomeFunc( int alpha, int& beta )

Question 3:
a. 1 14 3
   the value of b changes while passing reference
  
Question 4:
a.The actual parameter is never modified by execution of the called function.
   void call(int b);

   int a = 1;
   call(a);

   void call(int b)
   {
   b = 6 + b;
   }

   The value of b would change (7), but the value of a would still be unchanged (1).
  
Question 5:
a. The actual parameter can be modified by execution of the called function.

1. Given the function heading void GetNums( int howMany, float& alpha, float& beta ) which of the following is a valid function prototype for GetNums? a
1. Given the function heading void GetNums( int howMany, float& alpha, float& beta ) which of the following is a valid function prototype for GetNums? a
1. Given the function heading void GetNums( int howMany, float& alpha, float& beta ) which of the following is a valid function prototype for GetNums? a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site