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
Controls that are used to assess whether anything went wrong, such as unauthorized access attempts, are called ________ controls
disa [49]
Hey there,
The answer is <span>detective.

Hope this helps :))

~Top
</span>
4 0
3 years ago
Read 2 more answers
To include an online picture in a publication, navigate to the _____ tab.
tester [92]
Insert Tab.
Thank You!
4 0
3 years ago
In order for two computers to communicate via the internet, they must first locate one another. How do computers locate one anot
PolarNik [594]

by the IP address of the computer

a computer is located by the IP address

6 0
3 years ago
Which of the following values is an example of a floating point number?
Lunna [17]
A.19.67 is a floating point number
6 0
4 years ago
Which of the following is not a reason to choose a community college?
k0ka [10]
They do not make as big of a impression than a famous university when applying for jobs.
8 0
2 years ago
Other questions:
  • MTV can now be seen by most of the world's population. This is an example of
    7·1 answer
  • PLEASE HELP!!!!!!!!!!!
    7·1 answer
  • Which statement below is not true of EFS
    7·2 answers
  • Which of these shortcuts becomes available only when text is highlighted?
    10·1 answer
  • What is a society that has moved to the internet Rather than relying on physical media called
    11·1 answer
  • While investigating an email issue, a support technician discovers no users can access their email accounts on the company’s ema
    13·1 answer
  • Convert the expression ((a+b) + c * (d+e) + f) * (g+h) to a:
    13·1 answer
  • What one main difference between social media and traditional media such as television?
    12·2 answers
  • What would you need to do if you wanted a computer to always look for a bootable CD before looking to the local hard drive
    10·1 answer
  • why is it important for software manufacturers to update their programs to work with the latest operating systems? compuscholar
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!