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
Instructions:Select the correct answer.
Dafna1 [17]
It would be a audio file -B.
8 0
3 years ago
A digital computer has a memory unit with 16 bits per word. The instruction set consists of 72 different operations. All instruc
OLga [1]

Answer:

a. 7 bits b. 9 bits c. 1 kB d. 2¹⁶ - 1

Explanation:

a. How many bits are needed for the opcode?

Since there are 72 different operations, we require the number of bits that would contain 72 different operations. So, 2ⁿ ≥ 72

72 = 64 + 8 = 2⁶ + 8

Since n must be an integer value, the closest value of n that would contain 72 different operations is n = 7. So, 2⁷ = 128

So, we require 7 bits for the opcode.

b. How many bits are left for the address part of the instruction?

bits left = bits per word - opcode bit = 16 - 7 = 9 bits

c. What is the maximum allowable size for memory?

Since there are going to be 2⁹ bits to addresses each word and 16 bits  for each word, the maximum allowable size for memory is thus 2⁹ × 16 = 512 × 16 = 8192 bits.

We convert this to bytes

8192 bits × 1 byte/8 bits = 1024 bytes = 1 kB

d. What is the largest unsigned binary number that can be accommodated in one word of memory?

Since the number go from 0 to 2¹⁶, the largest unsigned binary number that can be accommodated in one word of memory is thus

2¹⁶ - 1

6 0
3 years ago
Types in java are divided into two categories. the primitive types are boolean, byte, char, short, int, long, float and double.
Rudik [331]
Types in java are divided into two categories. the primitive types are boolean, byte, char, short, not, long, float, and double. all other types are REFERENCE types
4 0
2 years ago
How does culture affect your life
777dan777 [17]
Culture identifies who you are, what you value, and how you act. 
5 0
3 years ago
What is the full form of ALU​
Alexandra [31]

Answer: arithmetic logic unit: the part of a central processing unit that performs arithmetic and logical operations.

Srry if it is wrong

I hope it  helps you

6 0
2 years ago
Read 2 more answers
Other questions:
  • Which of the following can be sources of sediment? A. fragments of other rocks B. chemicals and minerals dissolved in water C. s
    11·1 answer
  • "A(n) ___________ is a radio transceiver that plays the same role as a hub or switch in a wired network and connects the WLAN to
    14·1 answer
  • Assume the user types in 7 and 10. What is output by the following?
    10·1 answer
  • _______ is a form of crime that targets a computer system to acquire information stored on that computer system, to control the
    15·1 answer
  • All states that have altered judicial selection techniques in recent years have adopted some form of:
    5·1 answer
  • Programmers should strive to _____. increase coupling increase cohesion both of the above neither a nor b
    7·1 answer
  • Were does igneous rocks cool?
    9·1 answer
  • In a swap you need a variable so that one of the values is not lost ? Need help
    7·2 answers
  • Are you absent minded because you are thinking of an online activity?​
    12·1 answer
  • How is technology moving the business world forward?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!