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
Whitepunk [10]
4 years ago
12

Write a method named areFactors that takes an integer n and an array of integers, and that returns true if the numbers in the ar

ray are all factors of n (which is to say that n is divisible by all of them).
Computers and Technology
1 answer:
Airida [17]4 years ago
8 0

Answer:

The c++ program to show the implementation of parameterized method returning Boolean value is shown below.

#include<iostream>

using namespace std;

bool areFactors(int n, int arr[]);

int main()

{

   int num=34;

   int factors[5]={2, 3, 5};

   bool result;    

   result = areFactors(num, factors);

   if(result == true)

       cout<<"The number "<<num<<" is divisible by all factors."<<endl;

   else

       cout<<"The number "<<num<<" is not divisible by all factors."<<endl;        

   return 0;

}

bool areFactors(int n, int arr[])

{

   bool divisible=true;

   int flag=0;    

   for(int i=0; i<3; i++)

   {

       if(n%arr[i] != 0)

       {

           divisible = false;

           flag ++;

       }

   }

   if(flag == 0)

       return true;

   else

       return false;

}

OUTPUT

The number 34 is not divisible by all factors.

Explanation:

This program shows the implementation of function which takes two integer parameters which includes one variable and one array. The method returns a Boolean value, either true or false.

The method declaration is as follows.

bool areFactors(int n, int arr[]);

This method is defined as follows.

bool areFactors(int n, int arr[])

{

   bool divisible=true;

// we assume number is divisible by all factors hence flag is initialized to 0

   int flag=0;    

   for(int i=0; i<3; i++)

   {

       if(n%arr[i] != 0)

       {

           divisible = false;

// flag variable is incremented if number is not divisible by any factor

           flag ++;

       }

   }

// number is divisible by all factors

   if(flag == 0)

       return true;

// number is not divisible by all factors

   else

       return false;

}

The Boolean value is returned to main method.

bool result;

       result = areFactors(num, factors);

This program checks if the number is divisible by all the factors in an array.

There is no input taken from the user. The number and all the factors are hardcoded inside the program by the programmer.

The program can be tested against different numbers and factors. The size of the array can also be changed for testing.

You might be interested in
In Windows-based systems, a value that specifies the rights that are allowed or denied in an access control entry (ACE) of an ac
blsea [12.9K]

Answer:

C. Access mask discretionary.

Explanation:

Access_Mask is the value that defines the rights used in access control entries (ACE), this value identifies if the trustee is allowed to access a secured object.

It can define rights in three categories: Standard, specific and generic rights.

4 0
3 years ago
Fill in the blank with the correct response.<br> A _<br> is an unknown network.
alexgriva [62]

Answer:

ip address

Explanation:

please mark brainliest

7 0
3 years ago
Consider the practice of outsourcing programmers, a common practice in many U.S. businesses. Think about how this practice is us
GuDViN [60]

The practice of outsourcing programmers is known to be the act of  sharing or delegating as well as handing over control of programming and its associated tasks to any form of  external service provider that is said to be very good in that field and has the power and capabilities to handle the technical and operational areas of a programming project.

<h3>What is outsourcing and why is it always practiced?</h3>

Outsourcing is known to  be a kind of a business practice that entails the act of hiring a party that is known to be outside a company to carry out services or make goods that are said to be traditionally carried out in-house.

Note that The practice of outsourcing programmers is known to be the act of  sharing or delegating as well as handing over control of programming and its associated tasks to any form of  external service provider that is said to be very good in that field and has the power and capabilities to handle the technical and operational areas of a programming project.

Learn more about outsourcing  from

brainly.com/question/12101789

#SPJ1

5 0
2 years ago
Create a public non-final class named Larger parameterized by a type T that implements Comparable. (Please use T or the test sui
Liula [17]

Answer:

see explaination

Explanation:

class Larger<T extends Comparable<T>> {

public boolean larger(T[] arr, T item) {

if (arr == null || item == null)

throw new IllegalArgumentException();

for (int i = 0; i < arr.length; i++) {

if (item.compareTo(arr[i]) < 0) {

return false;

}

}

return true;

}

}

3 0
3 years ago
_____ is an advanced optical disc technology that can store up to 3.9 terabytes, roughly 75–150 times more data than the Blu-ray
Anettt [7]

Answer:

"The holographic versatile disc".

Explanation:

According to my research on optical disk technology, I can say that based on the information provided within the question the technology being described in the question is called a "The holographic versatile disc".

Unfortunately it is not shown as an available answer but it is the correct answer. This is the only optical disk technology capable of holding 3.9 terabytes of data as well as meeting the specs mentioned in the question.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

7 0
4 years ago
Other questions:
  • Select the correct answer. Ryan received an email from a person claiming that he is an employee of the bank in which Ryan has a
    11·2 answers
  • Lucy is completing a project as part of a science class using materials she found online. Which of the following is MOST LIKELY
    5·1 answer
  • An adjustable wrench's movable jaw is positioned <br> by​
    5·1 answer
  • A company has a number of employees. The attributes of EMPLOYEE include Employee ID (identifier), Name, Address, and Birthdate.
    11·1 answer
  • If a large organization wants software that will benefit the entire organization—what's known as enterprise application software
    7·1 answer
  • output device is any peripheral to provide data and control signal to ab information processing system​
    7·1 answer
  • Which feature do we most likely use to quickly change the background, fonts, and layout?
    12·1 answer
  • Help with Java, please!
    5·1 answer
  • How might a company gain followers on Twitter?
    7·1 answer
  • To have the full protection of the law, copyrights, patients, and ______ should be registered with the government.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!