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
nevsk
1 month 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:
Amiraneli [1K]1 month ago
5 0
Here's a C++ code snippet: #include <bits/stdc++.h> using namespace std; int main() { int n=50; int arr[n]; cout << "Enter 50 integers: "; for (int i = 0; i < n; i++) cin >> arr[i]; cout << endl; sort(arr,arr+n); for (int i = 0; i < n; i++) { cout << "pair which gives sum equal to " << 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; } The program will gather 50 integers from the user, sort them in ascending order, and identify all pairs that total to any of the array's elements, followed by printing those pairs.
You might be interested in
Assume that the reference variable r refers to a serializable object. Write code that serializes the object to the file ObjectDa
oksian1 [950]
To serialize an object, the following code can be used: FileOutputStream out = new FileOutputStream("ObjectData.dat"); ObjectOutputStream ostream = new ObjectOutputStream(out); ostream.writeObject(r); Explanation: For serializing an object, the writeObject method from the java.io.ObjectOutputStream class is utilized. The complete code snippet is as follows: import java.io.*; class Demo{ public static void main(String args[]){ try{ r = <reference to="" object="" be="" serialized="">; FileOutputStream out = new FileOutputStream("ObjectData.dat"); ObjectOutputStream ostream = new ObjectOutputStream(out); ostream.writeObject(r); ostream.close(); } catch(Exception e){ e.printStackTrace(); }} }. </reference>
5 0
2 months ago
Kirk found a local community college with a two-year program and he is comparing the cost with that of an out-of-state two-year
maria [1035]

What is the anticipated overall expense for one year at the local community college should Kirk reside at home?

Answer: $6845



What is the estimated total cost for one year at the out-of-state institution if Kirk resides on campus?

Answer: $30,566

5 0
2 months ago
Read 2 more answers
PHP is based on C rather than ______.
zubka84 [1067]
2b2t. Explanation: 2b2t.
8 0
2 months ago
Access to sensitive or restricted information is controlled describes which of the key communications and information systems pr
maria [1035]
Answer C: Security. It is crucial that communication and information systems maintain security to safeguard sensitive data from unauthorized access. Certain types of information, such as voices and data traffic, are of high sensitivity and must be adequately protected according to data privacy regulations.
4 0
1 month ago
They predicted another cold day in Seattle. They predicted another windy day in Seattle. Combine the sentences into one sentence
8_murik_8 [964]

Answer:

They forecasted yet another cold day in Seattle combined with another day of wind.

4 0
3 months ago
Other questions:
  • To reduce costs and the environmental impact of commuting, your company decides to close a number of offices and to provide supp
    14·1 answer
  • A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is the number of steps, and whose output i
    15·1 answer
  • Recall that with the CSMA/CD protocol, the adapter waits K. 512 bit times after a collision, where K is drawn randomly. a. For f
    5·1 answer
  • 1. Write the Python code needed to perform the following:2. Calculate state withholding tax (stateTax) at 6.5 percent3. Calculat
    9·1 answer
  • To finish creating a design for the webpage, use one shape to cut away part of the other. Create a 700 pixel by 700 pixel square
    10·1 answer
  • What is the other name designated to a game master of multiplayer online games (MMOs)?
    11·2 answers
  • 7.7 LAB: Using a while loop countdown Write a program that takes in an integer in the range 10 to 100 as input. Your program sho
    11·1 answer
  • For any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a space. Ex: I
    8·1 answer
  • Use Excel to develop a regression model for the Consumer Food Database (using the "Excel Databases.xls" file on Blackboard) to p
    13·1 answer
  • CHALLENGE ACTIVITY 2.9.1: Coordinate geometry. Determine the distance between points (x1, y1) and point (x2, y2), and assign the
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!