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
sweet-ann [11.9K]
3 years ago
6

Write a program that declares an array named myArray with 8 components of the type int. Initialize the array to 8 values that th

e user inputs (remember to prompt the user). Finally, pass the array as a parameter to a new function called filterEvens. This new function will display all of the even numbers in the array.
Computers and Technology
1 answer:
Savatey [412]3 years ago
6 0

Answer:

#include <iostream>

using namespace std;

void filterEvens(int myArray[]) {

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

     if(myArray[i]%2==0){

         cout<<myArray[i]<<" ";

     }

  }

}

int main(){

   int myArray[8];

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

       cin>>myArray[i];

   }

   filterEvens(myArray);

   return 0;

}

Explanation:

The solution is provided in C++

#include <iostream>

using namespace std;

The function filerEvens is defined here

void filterEvens(int myArray[]) {

This iterates through the elements of the array

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

This checks if current element is an even number

     if(myArray[i]%2==0){

If yes, this prints the array element

         cout<<myArray[i]<<" ";

     }

  }

}

The main begins here

int main(){

This declares an integer array of 8 elements

   int myArray[8];

The following iteration allows input into the array

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

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

<em>    }</em>

This calls the defined function filter Evens

   filterEvens(myArray);

   return 0;

}

You might be interested in
Who wrote Hamlet? <br><br>Brainliest for the right answer​
Alenkinab [10]

Answer:

William Shakespeare wrote hamlet

Explanation:

7 0
3 years ago
Read 2 more answers
How do graphic designers showcase their work?
Luda [366]

They showcase it digitally since their work is done on computers.

6 0
4 years ago
Read 2 more answers
True or False: if there are multiple operations inside a parentheses, you do not need to complete theses in the order of pemdas​
damaskus [11]

I believe this is false.

Happy to help.

5 0
4 years ago
Which soft skill involves the ability to work harmoniously with your colleagues and improve productivity?
Lina20 [59]
B.Teamwork is a soft skill involves the ability to work harmoniously with your colleagues and improve productivity. It is the collaborative effort of a team to complete a task or to achieve a common goal in the most effective and efficient way.  

 


4 0
3 years ago
Artificial intelligence seeks ways to improve a computer's capabilities in ____ and reasoning tasks. intellectual computational
Tatiana [17]
The answer is Computational
4 0
3 years ago
Other questions:
  • Complete each statement by choosing the correct answer from the drop-down menu.
    10·1 answer
  • What is an efficiency target? Give an example of setting an efficiency target
    11·1 answer
  • Which type of computer do dedicated gamers and video editors prefer?​
    11·1 answer
  • You’re responding to a troubleshooting ticket about a laser printer in HR that isn’t working. According to reports, the printer
    7·1 answer
  • Assume that we are using 0-1 integer programming model to solve a capital budgeting problem and xj = 1 if project j is selected
    6·2 answers
  • Fazer um programa em C++ que contenha 3 funções sendo:
    11·1 answer
  • Which of the following controls will provide an area in the form for the user to enter a name? a. button b. label c. text box d.
    8·1 answer
  • Write a program that completes the following requirements in C program:
    14·1 answer
  • What is 1 st genaration of computer ​
    14·2 answers
  • The short-range two-way communication technology behind contactless payments is called ____.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!