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
*
asambeis [7]

Answer:

I think they're all valid but the validility depends on the website your using the usernames on.

Explanation:

6 0
2 years ago
Which of the following is an advantage of using
SVETLANKA909090 [29]

Answer: preserves cell formatting and formulas

saves time

avoids copy-paste

organizes data so it is easier to draw comparisons

Explanation: just did it

8 0
3 years ago
Read 2 more answers
Together with some anthropologists, you’re studying a sparsely populated region of a rainforest, where 50 farmers live along a 5
Varvara68 [4.7K]

Answer:

Explanation:

Farmers are always both directly and indirectly connected to each other

Their network is mostly strong

Networks become weak only on the edges (ends) of the river but doesn't completely dimnish

With the available network length, the center of river bank forms the strongest network of all and becomes a key player in defining the balance property of overall network

The network is very well structurally balanced and we can see that through the below image

20 miles 10 20 30 40 50

See attachment file for diagram

Considering the total length of river as 50miles and and the center of the whole length will be at 25th mile. From that point, if we consider a farmer will be be having friends for a length of 20miles both along upstream and downstream.

By this he'll be in friend with people who are around 80% of the total population. As me move from this point the integrity increases and this results in a highly balanced structural network.

6 0
3 years ago
When do you use a for loop instead of a while loop? (There may be more than one answer.)
statuscvo [17]

Answer:

- You know how many times you want the loop to run.

- When there is a defined start and end.

Explanation:

Required:

When to use for instead of while loop?

First, it should be noted that both for loop and while loop are used for iteration. However, depending on the scenario; there is preference on one to the other.

The basic syntax of for loop is:

for(start;end;condition)\{\}

<em>The condition could either be increment or decrement</em>

The basic syntax of while loop is:

while(condition)\{\}

<em>The condition could be any condition whatsoever</em>

Analyzing the options one after the other.

1. How many times the loop to run.

The for loop is preferred here because of the simplicity of the for loop.

2. & 3. Both the for and while loops are used for code repetition and to perform number calculations

4. Defined start and end.

From the syntax of the for loop

for(start;end;condition)\{\}

<em />

A for loop has a definite start and end in its basic syntax and is more preferable to use instead of a while loop.

<em />

<em />

Hence, 1 & 4 answer the question

8 0
2 years ago
What are the primary benefits of relying on systems development standards?
Sunny_sXe [5.5K]

Answer:

The benefits of relying on System Development Standards is explained below.

Explanation:

There are many benefits of having a Well Defined Systems Development. It helps in having a pre - planned and well defined structure before the project starts. It helps in having a Clear view of the whole project and also each phase of the whole System Development. It helps in having an understanding of cost required and the revenues generated at each phase of the whole system development. It helps in having an understanding of the goal of each phase and procedures need to be followed for that particular goal. It also helps in having the quality checked and the improvements need to be made for the desired quality.

3 0
3 years ago
Other questions:
  • What are the first two lines of defense a company should take when addressing security risks?
    10·1 answer
  • What happens of the gamers dont follow the age ratings
    14·2 answers
  • Do you think boot-camp-style treatment centers can help young. People kick smartphones addictions?
    14·2 answers
  • TCP is the protocol responsible for the delivery of data on the Internet, and IP provides addresses and routing information.
    12·1 answer
  • Ebba received a message from one of her tech support employees. In violation of company policy, a user had downloaded a free pro
    14·1 answer
  • Which database item would show details such as a customer’s name, their last purchase, and other details about a customer?
    11·2 answers
  • Services such as water, electricity, and phone communications are called:
    7·1 answer
  • Digital on a smart phone means the camera is actually zooming in on the photo itself not the subject that you are shooting true
    8·1 answer
  • Is anyone a robIox moderator?
    13·2 answers
  • How much would it cost to get the screen replaced on a Moto G7?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!