1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
olya-2409 [2.1K]
2 years ago
5

Write a program that reads 20 integers from the user into an array and uses a function arrayMinimum that accepts an integer arra

y along with its size as parameters and returns the smallest element of the array. The program needs to output the result (the smallest array element).
Computers and Technology
1 answer:
neonofarm [45]2 years ago
6 0

Answer:

#include <iostream>

using namespace std;

int arrayMinimum(int myArray[], int myArraySize) {

int small = myArray[0];

for (int i = 0; i < myArraySize; i++) {

   if(myArray[i]<small){

small = myArray[i];

}

 }

 return small;

}

int main(){

   int myArray[20];

   for(int i =0;i<20;i++){

       cin>>myArray[i];          

   }

   cout<<"The smallest is: "<<arrayMinimum (myArray,20);

   return 0;

}

Explanation:

This solution is provided in c++

#include <iostream>

using namespace std;

This line defines the arrayMinimum function

int arrayMinimum(int myArray[], int myArraySize) {

This initializes the smallest of the array element to the first

int small = myArray[0];

This iterates through the array

for (int i = 0; i < myArraySize; i++) {

This if condition checks for the smallest

   if(myArray[i]<small){

The smallest is assigned to the small variable

small = myArray[i];

}

 }

This returns the smallest

 return small;

}

The main method begins here

int main(){

This declares an array of 20 elements

   int myArray[20];

The following iteration allows user input into the array

<em>    for(int i =0;i<20;i++){ </em>

<em>        cin>>myArray[i];          </em>

<em>    } </em>

This calls the method and returns the minimum

   cout<<"The smallest is: "<<arrayMinimum (myArray,20);

   return 0;

}

You might be interested in
A browser is an example of a. :
UNO [17]
A browser is an example of a system application
5 0
3 years ago
What is the main purpose of a graphic organizer?
timama [110]
B. To organize information using shapes.
8 0
3 years ago
Read 2 more answers
Assume that you are testing the Orders database introduced in Watt (2014) - Appendix C. Discuss the problems and possible conseq
madreJ [45]

Answer:

129 \frac{2}{?} 23.4. \div 164 \times 5y1 + . \\ .00487ggh

6 0
3 years ago
Choose the word that best completes this sentence. ________ can only grow and multiply within the cells of another living thing,
melomori [17]
The correct answer that would best complete the given statement above would be the word VIRUSES. Here is the complete statement. Viruses can only grow and multiply within the cells of another living thing, but they can remain active on a surface for several hours or days.
4 0
3 years ago
Which of the following is a command shell with a built-in scripting language?1. The Server Manager’s Roles and Features wizard2.
IgorLugansk [536]
Your kinda right but wrong
4 0
3 years ago
Read 2 more answers
Other questions:
  • Classify the given items as belonging to the public domain or protected by copyright law.
    6·2 answers
  • Ooooooooooooooooooooooooooooh im blinded by the lightssssssssss
    11·1 answer
  • Located toward the right of the status bar and contains buttons for zooming the display in and out
    13·1 answer
  • A. True <br> b. False: variables represent storage locations in the computer's memory.
    13·1 answer
  • Declare a char array named line of size 50, and write a statement that reads in the next line of console input into this array.
    6·1 answer
  • Which is a benefit of using the paste link option?
    15·2 answers
  • (I need help also can u guys just give me some example just in case I got confuse)
    13·1 answer
  • Create a two functions: first called grocery_cost(food), where food can be one item or a list of items from the stock and price
    7·1 answer
  • How many times do you return after the dateline ?
    12·1 answer
  • What is system software?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!