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
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
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started