457,750 Members | 980 Online Need help? Post your question and get tips & solutions from a community of 457,750 IT Pros & Developers. It's quick & easy.

# Can anyone help to solve this question?

 P: 3 By using an array, write a program: *That asks user to enter 10 integers *That display the 10 integers entered by a user *That display the sum of the 10 integers *That display the average of the 10 integers *That display the minimum and maximum of the 10 integers Please help me write this program. If possible, reply today. Thank you. Nov 12 '06 #1
5 Replies

 P: 2 You are lucky. I just read your post and I know the answer. I once recieved an assignment like this. Below are the answers. #include #include using namespace std; // Declare user-defined functions int min(int*, int); int max(int*, int); int main() { // Declare and initialise variables int number; for ( int i = 0; i < 10; i++ ) number[i] = 0; int sum = 0; double average = 0.0; int minNum = 0; int maxNum = 0; // Prompt user to enter 10 integers cout << "Please enter 10 integers.\n\n"; for ( int j = 0; j < 10; j++ ) { cout << "Enter integer #" << j + 1 << ": "; cin >> number[j]; cout << "\n\n"; } // Display user's entered integers cout << "These were the numbers which you have entered:\n\n"; for ( int k = 0; k < 10; k++ ) { cout << number[k] << " "; } cout << "\n\n"; // Display sum of integers for ( int l = 0; l < 10; l++ ) { sum += number[l]; } cout << "Sum of all integers: " << sum; cout << "\n\n"; // Display average of integers average = (double)sum / 10; cout << "Average of all integers: " << average; cout << "\n\n"; // Display minimum and maximum of the 10 integers minNum = min(number,10); maxNum = max(number,10); cout << "Minimum number: " << minNum << "\n\n"; cout << "Maximum number: " << maxNum << "\n\n"; system("pause"); return 0; } // main function int min( int* arrayVariable, int arraySize ) { int minNumber = arrayVariable; for ( int i = 1; i < arraySize; i++ ) if ( arrayVariable[i] < minNumber ) minNumber = arrayVariable[i]; return minNumber; } // min function: finds the minimum number in the array int max( int* arrayVariable, int arraySize ) { int maxNumber = arrayVariable; for ( int i = 1; i < arraySize; i++ ) if ( arrayVariable[i] > maxNumber ) maxNumber = arrayVariable[i]; return maxNumber; } // max function: finds the maximum number in the array Nov 12 '06 #2

 10K+ P: 13,264 You are lucky. I just read your post and I know the answer. I once recieved an assignment like this. Below are the answers. #include #include using namespace std; // Declare user-defined functions int min(int*, int); int max(int*, int); int main() { // Declare and initialise variables int number; for ( int i = 0; i < 10; i++ ) number[i] = 0; int sum = 0; double average = 0.0; int minNum = 0; int maxNum = 0; // Prompt user to enter 10 integers cout << "Please enter 10 integers.\n\n"; for ( int j = 0; j < 10; j++ ) { cout << "Enter integer #" << j + 1 << ": "; cin >> number[j]; cout << "\n\n"; } // Display user's entered integers cout << "These were the numbers which you have entered:\n\n"; for ( int k = 0; k < 10; k++ ) { cout << number[k] << " "; } cout << "\n\n"; // Display sum of integers for ( int l = 0; l < 10; l++ ) { sum += number[l]; } cout << "Sum of all integers: " << sum; cout << "\n\n"; // Display average of integers average = (double)sum / 10; cout << "Average of all integers: " << average; cout << "\n\n"; // Display minimum and maximum of the 10 integers minNum = min(number,10); maxNum = max(number,10); cout << "Minimum number: " << minNum << "\n\n"; cout << "Maximum number: " << maxNum << "\n\n"; system("pause"); return 0; } // main function int min( int* arrayVariable, int arraySize ) { int minNumber = arrayVariable; for ( int i = 1; i < arraySize; i++ ) if ( arrayVariable[i] < minNumber ) minNumber = arrayVariable[i]; return minNumber; } // min function: finds the minimum number in the array int max( int* arrayVariable, int arraySize ) { int maxNumber = arrayVariable; for ( int i = 1; i < arraySize; i++ ) if ( arrayVariable[i] > maxNumber ) maxNumber = arrayVariable[i]; return maxNumber; } // max function: finds the maximum number in the array I would not say that he/she is lucky. At this rate the OP will fail their C++ exam. Nov 12 '06 #3

 P: 2 I would not say that he/she is lucky. At this rate the OP will fail their C++ exam. What do you mean? Nov 13 '06 #4

 10K+ P: 13,264 What do you mean? I meant that giving people homework solutions instead of helping them get to the solution themselves will not help them or the programming community. Nov 13 '06 #5

 P: 3 How do I delete my BYTES account? I've only used Bytes once in 2006. Now after about 3 years, I've opened this Bytes community again. I'm the most unactive member in Bytes. So, how do I delete my account? Feb 22 '09 #6 