Question: 1) Write a function incrementByTen that uses a static variable count. Each call to the function should display the value of count and then increment

1) Write a function incrementByTen that uses a static variable count. Each call to the function should display the value of count and then increment count by 10. Initialize count to be 0 at the start of the program.

2) Write a function halve that takes an integer parameter and returns the value of that integer divided by 2.

3) Modify halve to receive its parameter by reference. This version of halve should not return a value and should instead alter the original value in its parameter.

4) Write a function minimumValue that prints and returns the minimum of its five integer parameters.

What is output by the following program segments?

1) int i; int values[ 10 ] = { 4, 1, 1, 3, 4, 9, 9, 2, 1, 7 }; cout << "Element" << setw( 13 ) << "Value" << endl; for ( i = 0; i < 10; i++ ) cout << setw( 7 ) << i << setw( 13 ) << values[ i ] << endl;

2) char string1[] = "How are you?"; cout << "string1 is: " << string1 << endl; for ( int i = 0; string1[ i ] != '\0'; i++ ) cout << string1[ i ] << "_";

3) #include using namespace std;

void mystery(); int main() { cout << "First call to mystery: "; mystery(); cout << " Second call to mystery: "; mystery(); cout << endl; } // end main // function mystery definition void mystery() { static int array1[ 3 ]; int i; cout << " Values on entering mystery: "; for ( i = 0; i < 3; i++ ) cout << "array1[" << i << "] = " << array1[ i ] << " "; cout << " Values on exiting mystery: "; for ( i = 0; i < 3; i++ ) cout << "array1[" << i << "] = " << ( array1[ i ] += 2 ) << " "; } // end function mystery

4)What is output by the following program and what algorith is implemented?

#include using namespace std; int main() {const int arraySize = 10; int a[ arraySize ] = { 2, 62, 4, 33, 10, 12, 89, 68, 45, 7 }; int i; int insert; cout << "Data items in original order "; for ( i = 0; i < arraySize; i++ ) cout << setw( 4 ) << a[ i ]; for ( int next = 1; next < arraySize; next++ ) { insert = data[ next ]; int moveItem = next; while ( ( moveItem > 0 ) && ( data[ moveItem - 1 ] < insert ) ) { data[ moveItem ] = data[ moveItem - 1 ]; moveItem--; } data[ moveItem ] = insert; } cout << " Data items in new order "; for ( i = 0; i < arraySize; i++ ) cout << setw( 4 ) << a[ i ]; cout << endl; } // end main

5) const int arraySize = 10; int a[ arraySize ] = { 4, 3, 7, 1, 13, 6, 0, 2, 9, 5 }; for ( int i = 0; i < arraySize; i++ ) { for ( int j = 0; j < a [ i ]; j++ ) cout << "*";}

6) #include using namespace std; int main() { int array[ 3 ][ 4 ] = { { 1, 2, 3, 4 }, { 2, 3, 4, 5 }, { 3, 4, 5, 6 } }; for ( int i = 0; i < 3; i++ ) { for ( int j = 0; j < 4; j++ ) { cout << array[ i ][ j ] << " "; } cout << endl; } } // end main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!