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
7nadin3 [17]
3 years ago
10

In this question, you must create a function in C++ using an external editor. When satisfied with your work, you shall attach it

here for full credit. All your source code must be in one cpp file. Write a function that accepts two parameters, the first shall be an array of integers, and the second shall be the length of the input array. The function you create shall process the input array and calculate if multiplying any two numbers within produces a result also contained in the array. If the product of two number equals a third contained in the array, the function shall return true (1). Otherwise, the function shall return 0. For example, array: [0,1,3,5,15], the function shall return True, for 3x5=15. array: [0,1,3,3,7], the function shall return True, for 1x3=3. (duplicates are possible) array: [2,-4,-3,10,8], the function shall return False array: [6,4,-3,-2,0,5], the function shall return True, for -3x-2=6 Do not assume well-formed input, so you must include some basic error checking. You may use the header files contained in the standard library and are encouraged to use data structures (like a map or set) to complete the problem efficiently
Computers and Technology
1 answer:
RideAnS [48]3 years ago
6 0

Answer:

See explaination

Explanation:

#include<iostream>

#include<map>

using namespace std;

bool contains(int arr[], int size){

map<int,int> nums;

for(int i=0; i< size; i++) nums[arr[i]]=1;

int product;

for(int i=0; i<size-1; i++){

for(int j=i+1;j<size;j++){

product = arr[i]*arr[j];

if (nums[product]==1) return true;

}

}

return false;

}

int main(){

int arr[] ={6,4,-3,-2,0,5};

cout<<boolalpha <<contains(arr,5)<<endl;

return 0;

}

You might be interested in
On the food inventory worksheet, enter a function in cell G1 that counts the number of Food Items. What formula would i use!? Th
Nataly [62]

COUNT function

COUNT function determines how many cells in a range contain a number. We use this function to get the number of entries in a number field in an array of numbers. The formula one can use is G1:[…..]: = COUNT(G1:[…..])






3 0
3 years ago
1. Discuss the pros and cons of human-computer interaction technology?
Lana71 [14]

!

gcoo!!Exykgvyukhhytocfplanationufvhyg:

3 0
3 years ago
What happens when two computers use the same IP address?
OLga [1]

Two computers can safely have the same IP address in certain cases. In most cases, if those two computers are on the same local network, it breaks connectivity for one or both of them. Internet protocols work by sending small, individually addressed messages. Each message can be routed differently.

I hope this helps you.

6 0
3 years ago
An arrangement in which local businesses team up with schools, hiring students to perform jobs that use knowledge and skills tau
Kazeer [188]

It is called a Cooperative program

A Cooperative program refers to a combination of both academic study and vocational activities in one curriculum of education. The purpose of this program is to provide the students with both knowledge in theory and practical skills that make them more prepared in the real world.


4 0
3 years ago
Read 2 more answers
Identifica una necesidad que implique la reducción de los efectos perjudiciales relacionados al uso de los recursos energéticos.
ELEN [110]

Answer:

Baje las persianas o cierre las cortinas en los días calurosos, para mantener la casa fresca y reducir el uso de ventiladores eléctricos o aire acondicionado. Deje que la ropa se seque naturalmente. Mantenga las tapas en las ollas cuando cocine para ahorrar energía. Use baterias recargables.

5 0
2 years ago
Other questions:
  • A flowchart would be an example of what kind of programming?
    12·1 answer
  • Which of them does not support decision making? Options DSS, GDSS, ESS All of above
    10·1 answer
  • The tone a writer takes is referred to as the writing _____.
    7·2 answers
  • True or False, PDF documents have many benefits, but their main disadvantage is that the formatting of their text and graphic el
    15·1 answer
  • When a server crashes and goes offline on a network, which of the following helps to determine that the server is unavailable?
    9·1 answer
  • What do you call the physical, touchable, materials parts of a computer system?
    7·1 answer
  • Data types influence the following in the workflow: (Select all that apply)a. the color choices and layout decisions around comp
    15·2 answers
  • 2:3:5<br>_ _ _<br>3 2 8<br><br><br><br>find ratio​
    5·1 answer
  • Which format of image files can be inserted in html?​
    8·2 answers
  • Where would you go to access frequently used icons?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!