1. Given the following statement, what would be the best heading for the DetermineAnswer( ….) function?

int aValue, result;

result = DetermineAnswer(27.83, aValue);

2. After completing the called function’s body, control is returned:

3. a valid function call for DetermineHighestScore?

void DetermineHighestScore(int val1, int val2)

4. Given the call to the function ComputeCost( ) shown below, What is the most appropriate heading for the function? The variable someValue is declared as an int.

someValue = ComputeCost(27.3);

5. The following is probably an example of a .

DisplayInstructions( );

6. a valid call to a function defined as shown below?

void InitializeValues( )

7. Given the following function definition, what would be a valid call? The variable someIntValue is defined as an int.

int GetData( int aValue, int bValue)

8. If a function is to be used to enter two values that will be used later in the program, what would be the most appropriate heading and call?

9. Given the following task, what would be the most appropriate function heading? A function receives three whole numbers as input. The values represent grades. They should be unchangeable in the function. The function should return the average with a fractional component.

10. Given the following task, what would be the most appropriate function heading?

Results have been calculated for taxAmount and totalSales. Write a function heading that accepts these values as input for display purposes.

11. Use the following function headings to answer the questions below:

int DetermineResult(int value1, double value2)

void DisplayResult(int value1, double value2)

int GetValue( )

a. How many parameters does each function have?

b. What is the return type for each of the functions?

c. Which of the preceding functions will have a return statement as part of its body?

12. A correct function to call a function that has the following heading would be:

int result(int anArray[ ][5], int num)

*******************************************************************

13. What is the output for total after the following segment of code executes?

int num = 3,

total = 0;

switch (num)

{

case 1:

case 2: total = 5;

break;

case 3: total = 10;

//break;

case 4: total = total + 3;

case 8: total = total + 6;

break;

default: total = total + 4;

break;

}

cout<"The value of total is "< total;

14. Consider the following if statement,

if (x >= y)

if (y > 0)

x = x * y;

else if (y < 4)

x = x - y;

Assume that x and y are int variables containing the values 9 and 3, respectively, before execution of the preceding statement. After execution of the statement, what value does x contain?

15. Rewrite the following compound expression as nested if statements:

if ((aValue > bValue) & (bValue == 10))

cout"Test complete";

16. Convert the following do. . .while loop into a for loop and a while loop.

int counter = 100;

do

{

coutcounter;

counter--;

}

while (counter > 0);

17. Assume an array called num is declared to store four elements. assign the value 100 to each of the

18. What is the effect of the following program segment?

int anArray[50];

int i, temp;

for (i = 0; i < 50; i++)

cin> anArray[i];

temp = 0;

for (i = 1; i < 50; i++)

if (anArray[i] < anArray[0])

temp++;

19. Using the following declaration:

int x[ ]= {12, 13, 14, 15, 16, 17, 18, 19};

What does x[8] refer to?

20. Which of the following adds 42 to the element at the fifth physical spot?

int x[ ] = {12, 13, 14, 15, 16, 17, 18, 19};

21. What output is produced by the following code?

int i;

int anArray [5];

for (i = 0; i < anArray.Length; i++)

anArray [i] = 2 * i;

for (i = 0; i < 5; i++)

coutanArray [i] " ";

22. If you declare an array as int anArray[5]; how can you double the value stored in anArray[2]

23. With the following declaration:

int points = {550, 700, 900, 800, 100};

What will be the effect of the statement points [3] = points [3] + 10;

24. With the following declaration:

int points = {300, 100, 200, 400, 600};

The statement points [4] = points [4-2]; will ……..

25. Assume a two-dimensional array called num is declared to hold four rows and seven columns. Assign the value 100 to the third physical column of each row?

26. Using the following declaration:

int x[ ]= {{12, 13, 14, 15 }, {16, 17, 18, 19 }};

What does x[2][4] refer to?

27. Which of the following adds 95 to the array element that is currently storing 14?

int x [ ][ ] = {{12, 13 }, {14, 15 }, {16, 17 }, {18, 19 }};

28. How many components are allocated by the following statement?

double values[ 3][ 2];

29. Given the declaration for values in 26 above, how would you store 0 in the

last physical location?

30. If you declare an array as int anArray[5][3]; how can double

the value stored in anArray[2][1]

31. With the following declaration:

int [ , ] points = {{300, 100, 200, 400, 600}, {550, 700, 900, 800, 100}};

The statement points[1][ 3] = points[1][ 3] + 10; will ………………..

Programming:

1.  Write down an input validation loop for an integer that should not be negative .

2.  Write down a function receives the right sides of a right angle triangle and calculates the size of the hypotenuse. The sizes of the right sides and the hypotenuse should be returned.

3.  Write down a function that finds the max and min values in a one dimensional array X of 10 elements. The locations of the min and max should be retuned.