answer.
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
mars1129 [50]
2 years ago
14

Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs

which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs.
Computers and Technology
1 answer:
Marrrta [24]2 years ago
5 0

Answer:

Here is code in C++.

#include <bits/stdc++.h>

using namespace std;

int main()

{  

int n=50;

   // integer array to store 50 integers

   int arr[n];

   cout << "Enter 50 integers: ";

   //read 50 integers into array

   for (int i = 0; i < n; i++)

       cin >> arr[i];

   cout << endl;

   

   //sort the array

   sort(arr,arr+n);

   

   // find all the pairs which give sum equal to any element of the array

   for (int i = 0; i < n; i++)

   {

       cout<<"pair which give sum equal to  ";

       cout << arr[i] <<" is :";

       for (int j = 0; j < n; j++)

           for (int k = j + 1; k < n; k++)

               if (arr[i] == arr[j] + arr[k])

                   cout <<"("<<arr[j]<<" & "<< arr[k] <<")"<<",";

       cout << endl;

       cout << "*******************************" << endl;;

   }

   return 0;

}

Explanation:

Read 50 integers into an array from user.Sort the array in ascending order.Travers the sorted array and find all pairs which give sum of equal to any element of the array.Then print all such pairs.

Output:

Enter 50 integers: 23 30 34 1 3 4 9 12 96 92 80 84 123 54 67 87 34 55 21 38 29 111 10 44 103 47 83 72 77 88 80 56 49 5 102 166 134 200 205 188 178 133 154 148 162 191 193 207 209 44                                                                                                                                                                    

 pair which give sum equal to  1 is :                                                *******************************

pair which give sum equal to  3 is :                                                     *******************************    

pair which give sum equal to  4 is :(1 & 3),                                         ******************************    

pair which give sum equal to  5 is :(1 & 4),                                         ******************************    

pair which give sum equal to  9 is :(4 & 5),                                         *******************************  

pair which give sum equal to  10 is :(1 & 9),                                       *******************************  

pair which give sum equal to  12 is :(3 & 9),                                       *******************************  

pair which give sum equal to  21 is :(9 & 12),                                      *******************************  

pair which give sum equal to  23 is :                                                    *******************************    

pair which give sum equal to  29 is :                                                    *******************************    

pair which give sum equal to  30 is :(1 & 29),(9 & 21),                        *******************************  

pair which give sum equal to  34 is :(4 & 30),(5 & 29),                     *******************************    

pair which give sum equal to  34 is :(4 & 30),(5 & 29),                     *******************************    

pair which give sum equal to  38 is :(4 & 34),(4 & 34),(9 & 29),  

.

.

.

.

  

You might be interested in
At age 16, Cheyenne just got her driver's license. She loves to drive and is thinking of becoming a truck driver, because she he
Ivenika [448]
<span> the answer would be: Does she have or can she develop the strengths needed for this type of work?</span><span />
6 0
2 years ago
Read 2 more answers
A workgroup database is a(n) _____ database
Step2247 [10]
It is a shared database
8 0
2 years ago
Haley's employer has asked her to review tens of thousands of social media posts about their company's products and compile this
ArbitrLikvidat [17]

Answer: Variety

Explanation:

According to the given question, Haley is dealing with the variety of the organization products posts on the social media networking as Haley's employer wants to comping all the data or information related to the products into the database system.

  • The database is one of the type of management system that manages all the database that are shared by the customers or users.
  • The main important function of the database is that it organize the data more accurately and properly in the system.
  • The database management system (DBMS) handle all the data in the system more effectively from the variety of the users.

Therefore, Variety is the correct answer.

7 0
2 years ago
A file ____ includes the three or four characters that follow the dot in the filename and identify the files type.
vodka [1.7K]
A file extension includes the three or four characters that follow the dot in the file name
6 0
2 years ago
Read 2 more answers
What is the value of the variable named myNum after the statements that follow are executed? var myNum = 14; var yourNum = 4; my
Lostsunrise [7]

Answer:

45

Explanation:

Initially, myNum is equal to 14 and yourNum is equal to 4

Then, myNum is incremented by 1 and becomes 15

Also, yourNum is decremented by 1 and becomes 3

Finally, myNum is set to myNum x yourNum, 15 x 3 = 45

8 0
2 years ago
Other questions:
  • Wesley has to create a web banner to announce a “Back to School” sale by an online retailer. Which information should he determi
    15·2 answers
  • In public-key encryption, the two keys–one for coding and one for decoding–are known as ________.
    6·1 answer
  • Which word in brackets is most opposite to the word in capitals? PROSCRIBE (allow, stifle, promote, verify)​
    14·2 answers
  • Which of the following can you NOT apply for at any FLHSMV office? A. Certificate of title B. License plates C. Vehicle registra
    15·2 answers
  • Monica needs a printer to use at home. She wants fine-quality prints at an affordable cost. Which printer will help her achieve
    9·1 answer
  • Suppose a computer has 16-bit instructions. The instruction set consists of 32 different operations. All instructions have an op
    6·1 answer
  • Information systems cannot solve some business problems. Give three examples and explain why technology cannot help.
    11·1 answer
  • A signal travels from point A to point B. At point A, the signal power is 100 W. At point B, the power is 90 W. What is the atte
    14·1 answer
  • The web development team is having difficulty connecting by ssh to your local web server, and you notice the proper rule is miss
    8·1 answer
  • Please help, Tech class!!
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!