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
Why backup system of data and software is necessary. ​
zavuch27 [327]

Answer:

The purpose of the backup is to create a copy of data that can be recovered in the event of a primary data failure. Primary data failures can be the result of hardware or software failure, data corruption, or a human-caused event, such as a malicious attack (virus or malware), or accidental deletion of data.

7 0
3 years ago
30 POINTS Conduct Interviews
Kitty [74]

Answer:

still need help with this if so lmk so o can help ya asap:)9

5 0
3 years ago
Which option in a Task element within Outlook indicates that the task is scheduled and will be completed on a later date?
dalvyx [7]

Answer:

in progress

Explanation:

it is being answered by the person

3 0
3 years ago
Remove gray from RGB Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers repres
sergejj [24]

Answer:  

Here is the C++ program:  

#include <iostream>   //to use input output functions    

using namespace std;   //to identify objects cin cout    

int main() {   //start of main method    

int red,green,blue,smallest;   //declare variables to store integer values of red,green, blue and to store the smallest value    

cout<<"Enter value for red: ";  //prompts user to enter value for red    

cin>>red;  //reads value for red from user    

cout<<"Enter value for green: ";  //prompts user to enter value for green  

cin>>green; //reads value for green from user    

cout<<"Enter value for blue: "; //prompts user to enter value for blue    

cin>>blue;   //reads value for blue from user    

//computes the smallest value  

if(red<green && red<blue) //if red value is less than green and blue values    

smallest=red;   //red is the smallest so assign value of red to smallest    

else if(green<blue)   //if green value is less than blue value    

smallest=green; //green is the smallest so assign value of green to smallest  

else //this means blue is the smallest    

smallest=blue;  //assign value of blue to smallest    

//removes gray part by subtracting smallest from rgb  

red=red-smallest; //subtract smallest from red    

green=green-smallest; //subtract smallest from green    

blue=blue-smallest; //subtract smallest from blue    

cout<<"red after removing gray part: "<<red<<endl;  //displays amount of red after removing gray    

cout<<"green after removing gray part: "<<green<<endl; //displays amount of green after removing gray  

cout<<"blue after removing gray part: "<<blue<<endl;  } //displays amount of blue after removing gray  

Explanation:  

I will explain the program using an example.    

Lets say user enter 130 as value for red, 50 for green and 130 for blue. So  

red = 130    

green = 50

blue = 130  

First if condition if(red<green && red<blue)   checks if value of red is less than green and blue. Since red=130 so this condition evaluate to false and the program moves to the else if part else if(green<blue) which checks if green is less than blue. This condition evaluates to true as green=50 and blue = 130 so green is less than blue. Hence the body of this else if executes which has the statement: smallest=green;  so the smallest it set to green value.    

smallest = 50    

Now the statement: red=red-smallest; becomes:    

red = 130 - 50    

red = 80    

the statement: green=green-smallest;  becomes:    

green = 50 - 50    

green = 0    

the statement: blue=blue-smallest; becomes:    

blue = 130 - 50    

blue = 80    

So the output of the entire program is:    

red after removing gray part: 80                                                                                                 green after removing gray part: 0                                                                                                blue after removing gray part: 80    

The screenshot of the program along with its output is attached.

5 0
2 years ago
20 POINTS!!!
Rina8888 [55]

Answer:

the third one

hope this helps

5 0
3 years ago
Other questions:
  • You receive an offer for a credit card that can be use to accrue points that
    11·1 answer
  • Jameis is researching at his local library when he finds a perfect source to use in his paper. When he goes to check the book ou
    12·2 answers
  • Answer these two if u can❤️
    5·2 answers
  • If there is a circuit that is being used 36 CCS then how much of that circuit is being used in Erlang?
    8·1 answer
  • Robert's employer has agreed to pay half the tuition for Robert to complete his college degree. This benefit is known as what?
    7·2 answers
  • Define stubs for the functions called by the below main(). Each stub should print "FIXME: Finish FunctionName()" followed by a n
    7·1 answer
  • Project: Math Tutor Program with Error Handling
    9·2 answers
  • Practicing touch typing allows you to create documents efficiently and accurately.
    13·1 answer
  • For two integers m and n, their GCD(Greatest Common Divisor) can be computed by a recursive function. Write a recursive method g
    8·1 answer
  • What is software engineering? What are the objectives of software engineering?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!