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
How does the Evaluate Formula dialog box help fix errors?
butalik [34]
C Bc I just did it and got it right
6 0
3 years ago
Read 2 more answers
Given a Fahrenheit value temperatureFahrenheit, write a statement that assigns temperatureCelsius with the equivalent Celsius va
Xelga [282]

Answer:

# include<iostream>

#include<conio.h>

using namespace std;

main()

{

float f, c;

cout<<"enter temperature in Fahrenheit ="

cin<<f;

c=(f-32)/1.8;

cout<<"/n Temperature in Celsius ="<<c;

getch();

}

Explanation:

The conversion formula from Fahrenheit to Celsius is given as:

C= (F-32) x 5/9

we take an input in Fahrenheit and put in above formula and covert it in Celsius.

7 0
2 years ago
Write a line of code to convert time to hours. Remember there are 60 minutes in an hour. Then write a line of code to calculate
DaniilM [7]

Answer:

float time_hourly=(time_min/60);

float speed_mph=(distance_mil/time_hourly);

Explanation:

I have taken a float variable time_hourly to convert the time given in minutes in hours.We need to divide the time in minutes by sixty since there are 60 minutes in an hour.

I have taken a float variable speed_mph to calculate the speed.Since we know the speed is distance/time and provided the distance is in miles and the time is in hours.

5 0
3 years ago
Read 2 more answers
Which pickaxe in minecraft to use?
Law Incorporation [45]

Answer:

Diamond pickaxe with efficiency 3

Explanation: It will mine quicker and you can just get unbreaking

6 0
2 years ago
Rick needs to find the lowest number in a set of numbers that includes decimals. Which statistical function in a spreadsheet wil
professor190 [17]
Umm

I’m in 10th grade so.....what is a spreadsheet and statistical function
4 0
3 years ago
Read 2 more answers
Other questions:
  • Explain how to use fortran programming in details
    14·1 answer
  • You install an M.2 SSD card in an M.2 slot on a motherboard. When you boot up your system, you discover the DVD drive no longer
    15·1 answer
  • "where is a cookie that is created during a web site visit​ stored?"
    9·1 answer
  • Write an examples of Output device, storage devices and inputs device 10 each excluding the common ones​
    5·1 answer
  • A company wants a recruiting app that models candidates and interviews; displays the total number of interviews each candidate r
    6·1 answer
  • How to solve a program that accepts a number as input and prints just the decimal portion
    15·2 answers
  • Which browser should you choose if you want all viewing information except thumbnail previews of websites?
    15·2 answers
  • Alan has introduced a new line of scooters on his website and is using a Google Display Ad campaign to promote them. He selects
    8·1 answer
  • Write program to read 10 random numbers, then find how many of them accept division by 4,
    6·1 answer
  • A web site that contains large numbers of misspelled words and grammatical errors fails which of these general criteria?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!