Its a c++ task.
Write a program that reads 10 integers from the user into an array and uses a function arrayMinimum that accepts an integer array a along with its size arraySize as parameters and returns the smallest array element. The program then outputs the result (the smallest array element).
#include <iostream> using namespace std; int arrayMinimum(int arr[], int size) { int min = arr[0]; for (int i = 0; i < size; ++i) { if (arr[i] < min) { min = arr[i]; } } return min; } int main() { int arr[10]; cout << "Enter 10 numbers: "; for (int i = 0; i < 10; ++i) { cin >> arr[i]; } cout << "Smallest number in the array is " << arrayMinimum(arr, 10) << endl; return 0; }
Get Answers For Free
Most questions answered within 1 hours.