Goku Uzumaki
2013-04-15 07:28:12 UTC
1) Write a program that uses a 10 element integer array and prompts the user for 10 integer values to populate the array. Create a function that is called from main() that is passed a pointer to the array and returns the largest value stored in the array. The main() function then outputs the largest value contained in the array. [This is what I have for this, don't know if it's right or wrong]
#include
using namespace std;
//function prototypes
int minimum(const int* values, size_t numValues);
int maximum(const int* values, size_t numValues);
int main()
{
const size_t maxValues = 10;
const int SENTINEL = -1;
int i;
int array[i];
int array[maxValues];
int min = array[0];
int max = array[0];
int numValues = 0;
while (array[i] != SENTINEL) //need this to stop if -1 is entered
{
cout <<"Enter up to 10 integers (-1 to stop):" <
cin >> array[i];
numValues++;
}
minimum (min, numValues); //not sure how to implement function
maximum (max, numValues); //not sure how to implement function
cout << "Values entered:" << array[i]<
//to find max/min
for (i = 0; i < numValues; i++)
{
if (array[i] < min )
{
min = array[i];
}
else if (array[i] > max )
{
max = array[i];
}
}
2) Write a program that prompts the user for a character string. Pass this string to a function called reverse() that you create as part of your program. The function reverse() then reverses the order of all of the characters in the string. The function main() then prints out the reversed string array. [I have NO idea]
Please help!