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
What data type can be used to hold any single character, including numbers and non-printing characters?
SVEN [57.7K]

Answer:

char

Explanation:

The character data type written as char holds any single character, numbers and non-printing characters. In java and most programming languages, the value of the character must be placed within single quotes. for example

char c = 'd'

char c = '9'

char c = '\t'

Are all valid declarations of a variable c as char and assigned d, then 9 and then used with a non-printing character (tab ) with the escape sequence.

8 0
3 years ago
Read 2 more answers
How do we make a acount
IRISSAK [1]
Press sign up and put your information in there. Then it should automatically make your profile.
8 0
3 years ago
Read 2 more answers
Assignment 4: Evens and Odds<br><br><br> How do I fix this?
skelet666 [1.2K]

There's definitely something wrong with your for loop. Try this:

for x in range(n):

You might want to check if all your print statements are correct. You might be missing just a period and it will be counted wrong.

6 0
3 years ago
The __________ unit is capable of mimicking the processor and of taking over control of the system bus just like a processor
Elden [556K]

The unit which is capable of mimicking the processor and of taking over control of the system bus just like a processor is: C) direct memory access.

<h3>What is computer memory?</h3>

A computer memory can be defined as the available space on an electronic device that is typically used for the storage of data or any computer related information.

<h3>What is a CPU?</h3>

CPU is an abbreviation for central processing unit and it can be defined as the main components of a computer because it acts as the “brain” of a computer and does all the processing, calculations, and logical control.

In Computer technology, direct memory access simply refers to the unit which is capable of mimicking the computer's processor and taking over control of the system bus just like a processor.

Read more on processing unit here: brainly.com/question/5430107

#SPJ1

Complete Question:

The __________ unit is capable of mimicking the processor and of taking over control of the system bus just like a processor.

A) interrupt-driven I/O

B) I/O channel

C) direct memory access

D) programmed I/O

5 0
2 years ago
list the six external parts of a computer system, identify which is the output device and which is the input device?
Mariulka [41]
1.mouse input
2.keyboard input
3.monitor output
4.speakers output
5.printer output , and input if has scanner
5.microphone input
4 0
4 years ago
Read 2 more answers
Other questions:
  • Number of byte required to store illumination
    13·1 answer
  • What are the keys in all rows that sit between the touch keys
    11·1 answer
  • In an image citation, what piece of information is listed first?
    14·1 answer
  • In statistics the mode of a set of values is the value that occurs most often. Write a program that determines how many pieces o
    10·1 answer
  • An argument is different from a parameter in that an argument
    11·2 answers
  • Write a function strlen_recursive which accepts a pointer to a string and recursively counts the number of characters in the pro
    6·1 answer
  • Write a program that dynamically allocates an array large enough to hold a user-defined number of test scores. Once all the scor
    5·1 answer
  • What is the output of the following program?
    5·1 answer
  • Helppppp mee eeeee eee
    14·2 answers
  • 1. How many bits would you need to address a 2M × 32 memory if:
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!