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]
3 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]3 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
Which unit of computer is used to processed data?​<br>Please help!!!!!!
RoseWind [281]

Hello There!

AnimeVines is here!

Is it Central Processing Unit?

HopeThisHelps!!

AnimeVines

7 0
3 years ago
Read 2 more answers
10. In step 4 of the CSMA/CA protocol, a station that successfully transmits a frame begins the CSMA/CA protocol for a second fr
Neporo4naja [7]

Answer:

It is done to avoid collision among the channel.

Explanation:

CSMA/CD stands for carrier sense multiple access/collision detection.

It is a media access protocol that tells the devices how to respond when a channel is used simultaneously by two devices. The main purpose is to manage the transmission when a collision is encountered.

In the given scenario when the channel is detected idle, the station does not transmits second frame in order to avoid collision. CSMA/CD protocol is designed so that after transmission of first frame, second frame transmission is started at step 2 instead of step 1.

Following is given the flow chart that depicts the working of the protocol CSMA/CD:

<h2> I hope it will help you!</h2><h2 /><h2 />

7 0
3 years ago
Advantages and disadvantages of screen reading​
STatiana [176]
It can make ur eyes blind blind that’s a disadvantage
7 0
3 years ago
Read 2 more answers
The Internet was first used by which of the following institutions?
m_a_m_a [10]

Answer: The answer is C. Us Department of Defense

Explanation:

6 0
3 years ago
Read 2 more answers
Which company provides a crowdsourcing platform for corporate research and development?
Nimfa-mama [501]

Answer:

D:InnoCentive

Explanation:

took test

7 0
3 years ago
Other questions:
  • Why would you convert your birth year to binary numbers?
    6·1 answer
  • What is A/B Testing
    10·2 answers
  • With respect to PERT and​ CPM, slack A. is a task or subproject that must be completed. B. marks the start or completion of a ta
    9·1 answer
  • THE bestValue PROBLEM Using the Camera structure defined in file p1.cpp, write the function named bestValue(). The function take
    13·1 answer
  • A two-dimensional array can be viewed as ___________ and _____________.
    10·1 answer
  • Sheila is using a process of saving files to her desktop and then renaming them. She is
    13·2 answers
  • The algorithm credited to Euclid for easily finding the greatest common divisor of two integers has broad significance in crypto
    11·1 answer
  • Given an integer n and an array a of length n, your task is to apply the following mutation to an: Array a mutates into a new ar
    5·1 answer
  • A different way of pronoucing the same words is called a _____
    15·1 answer
  • What does it mean to say that data in an Excel table is “dynamically linked” to a chart? What are the advantages of this feature
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!