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
.Write a C++ program that displays your name and address (if you value your privacy, a fictitious name and address).
olga_2 [115]

Answer:

#include <iostream>

using namespace std;

int main() {

   cout<<"My name is Rajat Sharma"<<endl<<"My address is Flat no=23 GH=5 Paschim Vihar New Delhi 110087 India"<<endl;

return 0;

}

Explanation:

The program is written in C++ language.In the program I have used cout to print my name and the address.First the name will be printed then the address in the new line endl is used for new line.To print any sentence just put them in double quotes.The same sentence in the program will be printed on the screen.

5 0
3 years ago
You are applying for a secretary position. You have many skills but which of the following would not be one to include on the ap
zepelin [54]

A. How many marathons you have run, because it doesn't relate to the job you're applying for.

6 0
3 years ago
Read 2 more answers
What is a PivotTable?
professor190 [17]

Answer:

d

Explanation:

6 0
3 years ago
Read 2 more answers
A__________is a system that incorporates all the technologies and applications found in a typical information system to gather,
Allisa [31]

Answer:

global information system (GIS)

Explanation:

A global information system (GIS) is an information system that works across national borders, facilitates communication between headquarters and subsidiaries in other countries, and incorporates all the technologies and applications found in a typical information system to gather, store, manipulate, and transmit data ...

6 0
3 years ago
Senioritis usually affects which of the following groups the most?
Dovator [93]
Generally we'd need "the following" if the question asks about it. Senioritis usually affects high school seniors IIRC.
6 0
3 years ago
Other questions:
  • Given an array declared to hold 100 values, the smallest index that can be used with the array is
    7·1 answer
  • ___ are controls through which a user can enter input data in a gui application. answer
    10·1 answer
  • What these large numbers in unemployment could mean long term for America?
    6·1 answer
  • John is considering his STEM education choices. He wants to begin working in the technology field as soon as possible.
    12·1 answer
  • Jenny is working on a laptop computer and notices that the computer is not running very fast. She looks and realizes that the la
    15·2 answers
  • When you're working with a word processing document and you press the del key, what happens?
    6·2 answers
  • ¡Hola! He visto en muchos comentarios de Twitter "svd" cuando alguien dice "dale fav a este Tweet y siganse entre ustedes" y en
    8·1 answer
  • PLEASE HELP ME!!! I REALLY NEED YOU TO HELP ME NOW!!!! THANKS!
    6·1 answer
  • What is the appropriate source to find information about an organization?
    12·1 answer
  • How many pages is 1500 words double spaced 12 font?.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!