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]
2 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]2 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
The first tools that analyzed and extracted data from floppy disks and hard disks were MS-DOS tools for ____ PC file systems.
netineya [11]

<u>The first tools that analyzed and extracted data from floppy disks and hard disks were MS-DOS tools for </u><u>IBM</u><u> PC file systems</u>. A file system is a structured representation of data and a set of metadata describing this data. The file system of the IBM supports stream input/output and storage management, providing a structure over all information stored in the system. A floppy disk consists of a thin plastic disk coated with magnetic material (it was designed by IBM in the early 1970s). A hard disk is fixed on the system unit. It is made up of several circular disks called platters. MS-DOS (Microsoft Disk Operating System) is a licensed operating system for use on microcomputers from various manufacturers.

6 0
3 years ago
How many generations of computer languages have there been since the middle of the 20th century?
evablogger [386]
4 generations hahahaha
3 0
2 years ago
Read 2 more answers
What three best practices can help defend against social engineering attacks?
lina2011 [118]

The three best practices that can help protect against social engineering are:

  • Be watchful of instructions to click on enticing web links.
  • Educate employees regarding policies.
  • Avoid disclosing your login details.
<h3>Social engineering</h3>

This refers to online crimes that are socially engineered or designed to trick victims into providing certain information or carrying out certain actions that would cause unknown harm to them or others.

For example, they may be tricked into revealing their security information or other personal information via email correspondence.

You can learn more about social engineering here brainly.com/question/26072214

#SPJ12

6 0
2 years ago
Outline a scenario in which you might be acting ethically but might still want to remain anonymous while using the Internet. How
kompoz [17]

Answer:

I would like to stay anonymous while criticizing the current government. As there have been many cases when people who wrote against the government's decisions were caught by the police.

So I would prefer to stay anonymous while commenting on various government policies. My friends would know about it because I share my posts only with them.

The government can know about my identity by ordering the social networking site to reveal it.

8 0
3 years ago
What function(s) does an interpreter perform with the instructions in a high-level programming language?
allochka39001 [22]

Answer:

Translates and Executes.

Explanation:

5 0
3 years ago
Other questions:
  • Identify the correct XHTML syntax for inserting an image as a hyperlink from the options provided. A. book.gif B. C. D.
    9·1 answer
  • When does the VB.NET programming environment start to operate?
    10·1 answer
  • Which task manager tab provides details about how a program uses system resources?
    14·1 answer
  • Write a program that prompts the user for a measurement inmeters and then converts it into miles, feet, and inches.
    9·1 answer
  • A number of related records that are treated as a unit is called
    6·1 answer
  • Which turn best describe news one is connected to the government and is used as a political tool more than as a business product
    12·1 answer
  • Assume that another method has been defined that will compute and return the student's class rank (Freshman, Sophomore, etc). It
    8·1 answer
  • The primary function of application software is to apply the power of the computer to enable people, workgroups, and the entire
    7·1 answer
  • 1: define about information system in computer?
    10·1 answer
  • What is essential for a good study routine? Select four options.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!