Write a program that declares an array named myArray with 8 components of the type int. Initialize the array to 8 values that the 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.

Answers

Answer 1

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

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

       cin>>myArray[i];

   }

This calls the defined function filter Evens

   filterEvens(myArray);

   return 0;

}


Related Questions

Emma wants an artificial intelligence system with limited information on botony to identify a type of plant from an image. which challenge of artificial intelligence is Emma likely to face in the situation . Emma is likely to face the challenge of *blank* complexity

Answers

Answer:

It focuses on one task and has no self awareness

During execution of main(), how many user-defined methods are called? a) public static double calcTax(double cost) { return cost * 0.15; } b) public static double calcShippingCost(double weight) { double cost; if(weight < 10) { cost = 10.0; }else{ cost = 15.5; } cost = cost + calcTax(cost); return cost; } c) public static void main(String args[]) { double cost1; double cost2; cost1 = calcShippingCost(7.5); cost2 = calcShippingCost(17.5); }

Answers

Answer:

b) public static double calcShippingCost(double weight) { double cost; if(weight < 10) { cost = 10.0; }else{ cost = 15.5; } cost = cost + calcTax(cost); return cost; }

The method is called twice with arguments 7.5 and 17.5 respectively.

Explanation:

The Java program defines three user methods including the main. In the main, the calShippingCost method is called twice with 7.5 and 17.5 respectively to return double number values to cost1 and cost2.

PYTHONSorting TV Shows (dictionaries and lists)Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. The input file contains an unsorted list of number of seasons followed by the corresponding TV show. Your program should put the contents of the input file into a dictionary where the number of seasons are the keys, and a list of TV shows are the values (since multiple shows could have the same number of seasons).Sort the dictionary by key (least to greatest) and output the results to a file named output_keys.txt, separating multiple TV shows associated with the same key with a semicolon (;). Next, sort the dictionary by values (alphabetical order), and output the results to a file named output_titles.txt.Ex: If the input is:file1.txtand the contents of file1.txt are:20Gunsmoke30The Simpsons10Will & Grace14Dallas20Law & Order12Murder, She Wrotethe file output_keys.txt should contain:10: Will & Grace12: Murder, She Wrote14: Dallas20: Gunsmoke; Law & Order30: The Simpsonsand the file output_titles.txt should contain:DallasGunsmokeLaw & OrderMurder, She WroteThe SimpsonsWill & Grace

Answers

Answer:

with open("file1.txt", "r") as file:

lines = file.readlines()

mydict = dict()

for x in range(0, len(lines) - 1, 2):

mydict[lines[x]] = lines[x-1]

dict_keys = sorted(mydict.keys)

sorted_dict ={}

for key in dict_keys:

sorted_dict[key] = mydict[key]

with open("output_keys.txt", "a+") as writn:

for key, value in sorted_dict.items():

writn.write(key: value)

writn.write("\n")

dict_values = sorted(mydict.values)

with open("output_titles", "a+") as title:

for name in dict_values:

title.write(name)

title.write("\n")

Explanation:

The python program above reads in the file context, files.txt, and creates a dictionary of the file with the number of seasons as the key and movie title as the value. The sorted dictionary is saved in the output_keys.txt file and the titles in output_titles.txt file.

PLZ HELP ASAP

(03.11 MC)


Your brother used your computer to complete his homework last night, and now your login password no longer works. What question frames your problem into a question to help reach a solution?


What is wrong with my brother?

Did this computer get a virus?

Why is this computer broken?

Did my brother change the password?

Question 2(Multiple Choice Worth 5 points)

(03.11 LC)


This option in the Help tab allows you to leave a suggestion about how to improve Office Online.


Accessibility

Contact Support

Feedback

What's New

Question 3(Multiple Choice Worth 5 points)

(03.11 MC)


You invited two of your friends over for movie night. One of your friends brought her sister, so now there are more people than you planned for. You want to pass out small bags of chips, but you only have three and you need four for everyone to have one. What is the best solution for the problem?


Ask your mom to go to the store to buy more chips.

Don't offer your friends any snacks.

Pour the small bags into a bowl and share the chips.

Tell your friend's sister she can't have one.

Question 4(Multiple Choice Worth 5 points)

(03.11 LC)


What is the first step in finding a solution to a problem?


Choose a solution.

Think of options to solve the problem.

Try the solution.

Turn the problem into a question.

Question 5(Multiple Choice Worth 5 points)

(03.11 MC)


Rafael likes to stay up to date with the latest technology and learn about updated features on his favorite software, Word Online. How can Rafael stay up to date on changes to the features of Word Online?


Ask a question in the box under the Help tab.

Contact customer support every week.

Go to the What's New option under the Help tab.

Provide feedback on features he wants to see.

Answers

Answer:

Did this computer get a virus.

Explanation:

The brother can't change the password because it required him to get the old password before changing it.

Drag each label to the correct location on the image
Identify the parts of the table,

primary key
field
record
table

Answers

Answer:

Explanation:

because i took the test

Users access servers located on a server VLAN and servers located in departmental VLANs. Users are located in the departmental VLAN. What is the expected traffic flow from users to servers

Answers

Answer:

Most of the traffic will have to be multilayer switched.

Explanation:

This is often referred to when a layer 3 switch is seen to add tons of flexibility to a network. As seen in in the above VLAN connection, it serves as a switch to connect devices found on same subnet a lightning speed and are seen also to posses IP routing intelligence which is seen as a doubling up built in it which serves as a router. It seen in most cases to support routing protocools, inspect incoming packages and most times checking sources and destination addresses which are been worked with.

In a gig setting (ie low light), the ISO should be set......?

Answers

wha do you mean by this question

PLEASE FASTTTTT



Which reasons explain why computer programmers use IDEs? Select all that apply.

An IDE provides an integrated work environment for the programmer.

An IDE writes the code for the programmer.

An IDE helps programmers automate repetitive tasks.

An IDE helps link code.

Answers

Answer:

Integrated work and repetitive tasks

Answer:

A C D

Explanation:

Cryptocurrencies are digital tokens that are created independently of government money, and can act as a medium of exchange and store of value. Which other instrument could most reasonably fulfill the same function

Answers

Answer:

Gold

Explanation:

From the question, we are informed about Cryptocurrencies which are digital tokens that are created independently of government money, and can act as a medium of exchange and store of value. One of other instrument that could most reasonably fulfill the same function is Gold. A medium of exchange can be regarded as a intermediary instrument which is a function of money that facilitate trade or purchase and selling between seller and buyers, and it must be accepted as payment for transactions. Such intermediary instrument as a medium of exchange are Gold, salt as well as stone. Gold was chosen by most of the commodity-money advocates as a medium of exchange as a result of the intrinsic property it posses, and it's fixed stock value

Which IDE component provides keyword highlighting and text auto-completion?

Answers

Answer choice: OD.code editor
Explanation:PLato

IDE component that provides keyword highlighting and text auto-completion is Source code editor.

What is an integrated development environment (IDE)?

An integrated development environment (IDE) exists as software for construction applications that integrates common developer tools into a single graphical user interface (GUI). An IDE typically consists of:

Source code editor: A text editor that can help in writing software code with components such as syntax highlighting with visual cues, furnishing language-specific auto-completion, and inspecting for bugs as code exists being noted.

Therefore, the correct answer is the Source code editor.

To learn more about Source code editor

https://brainly.com/question/10285442

#SPJ2

What is the practice of distributing responsibility among multiple people so that no one person has full control of
everything?
Separation of duties
Responsibility sharing
Separation of responsibility
None

Answers

Answer:

If the responsibilities are distributed ,the disputes amongst people wont take place because their wont be any partiality, everyone would be equal. Moreover it is difficult for one person to control everything at once and multiple people would help the work to be organized as everyone will have their own part of work which is supposed to be fulfilled.

james creates a piece of artwork that consists of circles and squares. he carefully avoids using random shapes that do not fit into the design. what is james trying to achieve? a. dominance b. harmony c. gradation d. placement e. contrast

Answers

answer:
b.harmony
explanation:
to make it harmonious and neat

Answer:

ITS B

Explanation:

i just know

Block elements start a new line when rendering? (true or false)

Answers

Answer:true

Explanation:

You plan on taking a five-part exam, each part worth 50 points. The maximum
score is measured in the
A. ones
B. tens
C. hundreds D. thousands

Answers

Answer:

okk I will do

Explanation:

mark me as brainliest and follow and like my answer

a is the correct answer of this question

A serial schedule A. Is just theoretical and cannot be implemented in real life B. Needs the current Xact to finish before another one starts C. Is always sorted sequentially in ascending order by transaction ID D. Can have a dirty read anomaly

Answers

Answer: B. Needs the current Xact to finish before another one starts.

Explanation:

A serial schedule is a schedule whereby for a transaction to start, one must be completed first. The transactions are done one after the other.

In this case, when the cycle of a transaction have been completed, then the next transaction can begin. Therefore, the answer will be option B "needs the current Xact to finish before another one starts".

Imagine that you are preparing a multimedia presentation. What are the four things you need to consider when getting started?

Answers

Answer:

I need to consider my topic, my audience, the purpose of my presentation, and my method for giving it.

Explanation:

This is the sample response

The things you should consider when making a multimedia presentation are a text, images, audio, video, and animation.

What is a multimedia presentation?

A multimedia instructional message is a presentation of words and images that are intended to promote meaningful learning. Multimedia displays facilitate faster greedy of ideas and concepts than what simple oratory reasons can hope to achieve.

As a result, multimedia-based completely coaching reduces the cost of training sessions while improving the overall quality of such classes.

Multimedia is prevalent in our lives today because when we connect and communicate with more than one medium, we use multiple of our senses. The use of a variety of creative or communicative media such as this facilitates making an idea or presentation sparkle and exciting, as well as providing more insight.

Therefore, When creating a multimedia presentation, you should consider the text, images, audio, video, and animation.

To learn more about the multimedia presentation, refer to the below link:

https://brainly.com/question/27800459

#SPJ2

I need help with this its due today ahhhhhhh

Answers

3rd and 4th sentence

1st question just take a hint

Write a C++ program to define an abstract class in polymorphism?

Answers

Answer:

Following are the program to this question:

#include <iostream>//header file

using namespace std;//namespace

class Val //defining abstract class

{

  public://use access specifier

     virtual int squ()=0;//declaring a method squ  

     void setval(int x) //defining a method setval

     {

        a=x;//holding value in a variable

     }

  protected://use access specifier

     int a;//defining integer variable

};

class square: public Val //defining a class square that inherit abstract class

{

  public://use access specifier

   int squ() //defining squ method

   {  

   return (a*a); //return square value

   }

};

int main() //main method

{

 square s;//creating class object

 s.setval(5);//calling setval method

 cout << "The square value is: " << s.squ() << endl;//print value by calling squ method

}

Output:

The square value is: 25

Explanation:

In the above code a two-class "Val and square" is declared, in which val is abstract class, in a method squ is declared, and setval is used to set the value.

In the next step, the square class inherits Val and defines the squ method, and uses the return keyword to return its calculated value.

In the main method square class object is created and set the setval value and call the squ method and print its value.    

What is a feature of Print Preview

Answers

Answer:

It shows you how the paper would look as if u printed it.

Explanation:

Answer:

is a functionality that lets users see the pages that are about to print.

Explanation:

allowing the users to see exactly how the pages will look when they are printed.

. The add() method of the ArrayList class can: A. Shift indexes in the list B. Creates a new Value at the end of the list C. Creates a new Value at any specified index D. Increases the size of the list E. All of the Above

Answers

Answer:

All of the Above

Explanation:

The add() method of the ArrayList class is a Java function that jas the capability of adding elements to an array list. In order to add elements to the great list, this java function does the following work as well

1. It shift indexes in the list

2. It establishes a new Value at the end of the list

3. It creates a new Value at any specified index

4. It expands the size of the list.

Hence, in this case, the correct answer is option E. "All of the above."

I need help with completing this python code.Complete the Car class by creating an attribute purchase_price (type int) and the method print_info() that outputs the car's information.Ex: If the input is:2011180002018where 2011 is the car's model year, 18000 is the purchase price, and 2018 is the current year, then print_info() outputs:Car's information: Model year: 2011 Purchase price: 18000 Current value: 5770Note: print_info() should use three spaces for indentation.class Car:def __init__(self):self.model_year = 0# TODO: Declare purchase_price attributeself.current_value = 0def calc_current_value(self, current_year):depreciation_rate = 0.15# Car depreciation formulacar_age = current_year - self.model_yearself.current_value = round(self.purchase_price * (1 - depreciation_rate) ** car_age)# TODO: Define print_info() method to output model_year, purchase_price, and current_valueif __name__ == "__main__":year = int(input())price = int(input())current_year = int(input())my_car = Car()my_car.model_year = yearmy_car.purchase_price = pricemy_car.calc_current_value(current_year)my_car.print_info()

Answers

Answer:

class Car:

   def __init__(self):

       self.model_year = 0

       # TODO: Declare purchase_price attribute

       self.purchase_price = 0

       self.current_value = 0

   def calc_current_value(self, current_year):

       depreciation_rate = 0.15

       # Car depreciation formula

       car_age = current_year - self.model_year

       self.current_value = round(self.purchase_price * (1 - depreciation_rate) ** car_age)

# TODO: Define print_info() method to output model_year, purchase_price, and current_value

   def print_info(self):

       print("Model year: ",self.model_year)

       print("Purchase year: ",self.purchase_price)

       print("Current value: ",self.current_value)

def main():

   year = int(input())

   price = int(input())

   current_year = int(input())

   my_car = Car()

   my_car.model_year = year

   my_car.purchase_price = price

   my_car.calc_current_value(current_year)

   my_car.print_info()

if __name__ == "__main__":

   main()

Explanation:

The Car class in the python program is used to create a car object instance with class methods model_year, purchase_price, and calc_current_value, which accepts as arguments, year, price and current_year respectively. The main function runs if only the python module is run and interpreted to print out the year and current price of a car object instance defined.

. Write an interrupt driven program that uses Port H pin 0 to detect an interrupt and multiply PORTB by 2 if the interrupt request is generated. IRQ should be asserted at falling edge. Write main program as well as ISR.

Answers

Problem-1. Write an interrupt driven program that uses Port H pin 0 to detect an interrupt and multiply PORTB by 2 if the interrupt request is generated. IRQ should be asserted at falling edge. Write main program as well as ISR. (15 points)

What is an OS? Explain the objectives of an OS.​

Answers

Answer:

operating systems is a group of computer programs that is responsible for the management and coordination of activities and the sharing of the resources of that computer.

objective

1 to make the computer system convenient and easy to use for the user.

2 to use the computer hardware is a efficient way by handling the details of the operations of the hardware

Why is making a model, or prototype, important in the design process?

Answers

Explanation:

to size up and define your works organize and having a creative thoughts and imaginations in it to properly execute the measurement of the clothes.

Write a program that reads 20 integers from the user into an array and uses a function arrayMinimum that accepts an integer array along with its size as parameters and returns the smallest element of the array. The program needs to output the result (the smallest array element).

Answers

Answer:

#include <iostream>

using namespace std;

int arrayMinimum(int myArray[], int myArraySize) {

int small = myArray[0];

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

   if(myArray[i]<small){

small = myArray[i];

}

 }

 return small;

}

int main(){

   int myArray[20];

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

       cin>>myArray[i];          

   }

   cout<<"The smallest is: "<<arrayMinimum (myArray,20);

   return 0;

}

Explanation:

This solution is provided in c++

#include <iostream>

using namespace std;

This line defines the arrayMinimum function

int arrayMinimum(int myArray[], int myArraySize) {

This initializes the smallest of the array element to the first

int small = myArray[0];

This iterates through the array

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

This if condition checks for the smallest

   if(myArray[i]<small){

The smallest is assigned to the small variable

small = myArray[i];

}

 }

This returns the smallest

 return small;

}

The main method begins here

int main(){

This declares an array of 20 elements

   int myArray[20];

The following iteration allows user input into the array

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

       cin>>myArray[i];          

   }

This calls the method and returns the minimum

   cout<<"The smallest is: "<<arrayMinimum (myArray,20);

   return 0;

}

Dynamic programming does not work if the subproblems: ___________

a. Share resources and thus are not independent
b. Cannot be divided in half
c. Overlap
d. Have to be divided too many times to fit into memory

Answers

Answer:

A. Share resources and thus are not independent

Explanation:

This would be the answer. If this is wrong plz let me know

Assume you have the all_info list that is given in the Do It Now problem 1. This list includes the grades of 4 courses for 4 students. Write a code that asks a name from the user. Then it will search for that name in the list all info. Of the name exists in the list, the program will display the programming grade of that student. For example, if the user enters 'Sarah ' the program will display 90. If the user enters a name that is not in the list, such as 'Jack', the program will display an error message such as 'Sorry, but this student is not in the list'.

Answers

Answer:

titles =['name', 'physics', 'chemistry', 'math', 'programming']

student_1 =['Kathy', 90, 80, 75, 100]

student_2 =['John', 65, 84, 79, 90]

student_3 =['Joe', 45, 89, 100, 10]

student_4 =['Sarah', 68, 89, 93, 90]

all_info =[titles, student_1, student_2, student_3, student_4]

student = input("Enter student's name: ")

student_list = [name[0] for name in all_info]

if student in student_list:

   print(all_info[student_list.index(student)][4])

if student not in student_list:

   print("Student name does not exist.")

   

Explanation:

The python program prompts for user input "student" and the input is used to search and return the result of the student in the programming exam. If the name is not in the student_list, the program print an error message.

All of the following are standards that enable programs to receive data from and display data to a variety of mobile and desktop devices except ________. Group of answer choices CSS 3 html5 javascript SOA AOL

Answers

Answer:

AOL

Explanation:

Some of the standards that enable programs to receive data from and display data to a variety of mobile and desktop devices includes;

I. CSS 3: it is a framework used for providing various styles used in web design.

II. HTML 5: this is a hypertext markup language used for creating web pages or website.

III. Javascript: it is a software framework that allows software components to send and receive data through a database.

IV. Service oriented architecture (SOA): this is an architectural pattern which allows various software application components to provide specific services to other applications through a network.

All of the following standards listed above enable programs to receive data from and display data to a variety of mobile and desktop devices except AOL. AOL is an acronym for American Online and it is typically used for providing internet connection through a dial-up.

All of the following are standards that enable programs to receive data from and display data to a variety of mobile and desktop devices except AOL.

The following information should be considered:

AOL means America Online .CSS3 is Cascading Style Sheet this standard represent the look and formatting of a document HTML5 is markup language .Javascript is Scripting language for WWW .SOA is Service Oriented Architecture this is type of standards provide service to the application component via communication protocol in network.

Learn more: brainly.com/question/17429689

Let us consider the easiest sorting algorithms – Maxsort. It works as follows: Find the largest key, say max, in the unsorted section of array (initially the whole array) and then interchange max with the element in the last position in the unsorted section. Now max is considered part of the sorted section consisting of larger keys at the end of the array. It is no longer in the unsorted section. Repeat this until the whole array is sorted. a) Write an algorithm for Maxsort assuming an array E contains n elements to be sorted, with indexes 0, 1,…,n-1. b) How many comparisons of keys does Maxsort do in the worst case and on average? Submit source code, test cases, results, and the answers to part (b)

Answers

Answer:

count = 0

for x in range(len(array)):

if count == Len(array) -1:

break

max = max(array[:-1 - count])

count += 1

if array.index(max) == -1:

break

else:

hold = array[-1]

array[-1] = max

array[array.index(max)] = hold

Explanation:

The python program is an implementation of a maxsort. The for loop iterates over the array, getting the maximum number for each reduced array and swaps it with the corresponding last items.

You need expensive cameras, lenses, and equipment to get good wildlife photographs.
A. True
B. False

Answers

B. False, obviously you would need a decent camera but other factors like exposure, brightness, and contrast can turn a regular picture into a very visually pleasing one. Yes, you can get better pictures with better equipment. With patience and the right setting you will still be able to get very good pictures

Answer:

False

Explanation:

Other Questions
The blue-print of life. Type of Nucleic acid that controls all cellular activity. A. mRNA B. rRNA C. DNA D. tRNA Select the correct texts in the passage.Which two words help find the meaning of the word antiquated in the passage?Jared had been tinkering with the old-fashioned record player he found in the junk plle for some time but could not get it towork. The parts he needed to fix it were either obsolete or unavailable or pricy. It would have been cool to get it working,but it was too antiquated.ResetNext Select the choice that contains no shifts in either verb tense or point of view. A. The marigolds were blossoming just as a sudden hailstorm had been destroying all of my annual flowers. B. No sooner had the marigolds blossomed than a sudden hailstorm destroyed all of my annual flowers. C. A sudden hailstorm was destroying my annual flowers when the marigolds blossomed. im really confused someone plz help what is the mass of 1.506 x 10^24 atoms of Argon How does the sentence "For years now I have heard the word Wait!'" contribute to the text as a whole? It shows that King acknowledges that his critics have good intentions. It alludes to a historical example that King uses as evidence to support his argument. It emphasizes that King's critics who promote patience have not produced change. It shows that King's idea of justice is incompatible with the public's. What are the differences between accurate and exact ? WILL GIVE BRAINASAP The only safe cannabis practice is abstinence. If choosing to use cannabis, what are safer practices for teens? Research examples and create a list for the next class.I want a clear answer :) What did the crop lien law require of debtors? The acceleration of an object due to gravity is 24 feet per second squared. What is the acceleration due to gravity in inches per second squared?288 inches per second squaredB2 inches per second squared72 inches per second squaredD3,456 inches per second squared Anyone? please help me Im absolutely lost on this one here :,) A taxi charges a flat rate of $1.75, plus an additional $0.65 per mile. Erica has at most $10 to spend on the cab ride. How far can Erica travel? The volume of a cone is represented by the formula V = 1 T?n. If the volume of a cone is 30rt and the height is 2.5, what is the radius of the cone? PLEASE HELP!Part AHow does the shift in paragraph 4 most impact the story?A) By introducing a new character, paragraph 4 develops a sense of mystery.B) By describing why the grandmother left, paragraph 4 introduces an element of surprise.C) By introducing a new character, paragraph 4 heightens the tension between characters.D) By describing why the grandmother left, paragraph 4 increases a sense of unreality.Question 2Part BWhich quotation from elsewhere in the passage best reflects the effect caused by the shift in paragraph 4?A) "She was forced to work...from dawn to dusk, while her new stepmother and stepsisters lounged around..." (paragraph 5)B) "And on top of everything else, she cared for the familys chickens and goats..." (paragraph 6)C) "...because she always showed him a happy, kind face; he saw none of her darkness." (paragraph 8)D) "...see the beauty of the sky and the peaked mountains and fertile orchards when she was outside working?" (paragraph 9) please answer; ill give brain HELP QUICK THIS IS DUE TODAY Addie owns the Knead to Know Bakery and has decided to open a website.Take a look at her ideas and select the best domain name by crossing off the rest.Take a look at her ideas and select the best domain name by crossing off the rest. 61 divided by 3427? Part of the sun or moon is visibleA.coronaB.partial eclipse Plz in need the answer ASAP!!