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]
2 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]2 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
Which function in Spell Checker should Patrick use if he makes the same mistake frequently when typing emails?
Olin [163]

Answer:

Explanation:

Click Spelling and Grammar and choose AutoCorrect,

4 0
3 years ago
I dunno what to write my memo thing about ⁻³⁻
Alex73 [517]

Answer:

Wdym? I could help u

Explanation:

5 0
3 years ago
Read 2 more answers
Create a poem about MS powerpoint presentation
iren2701 [21]
You could use poem generator online or see samples and change some words
5 0
2 years ago
Thanks for help evreybody
ladessa [460]

Answer:

np

Explanation:

7 0
2 years ago
Read 2 more answers
1 byte =???? bit<br> please help me
diamong [38]

Answer:

8 bits make a byte

Explanation:

8 bits make a byte

7 0
2 years ago
Other questions:
  • Tom's Art Supplies used to sell art supplies through mail order catalogs, but the company's order takers often had difficulty de
    5·1 answer
  • Which of the following is a list of input devices?
    11·1 answer
  • During which part of geologic time were dinosaurs most common?
    11·2 answers
  • Which of these statements about tags is false?
    12·1 answer
  • What is 4x+2x(-3-3) thanku
    11·2 answers
  • Write a function template that accepts an argument and returns its absolute value. The absolute value of a number is its value w
    11·1 answer
  • Guys im getting the ps5 tomorrow :)​
    5·2 answers
  • Suppose a large group of people in a room were all born in the same year. Consider the following three algorithms, which are eac
    8·1 answer
  • Does anyone know how to permanently delete photos on a dell computer? For my cousin.
    12·1 answer
  • Write code that declares a variable named minutes, which holds minutes worked on a job,
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!