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
irina [24]
3 years ago
9

Array Challenge Have the function ArrayChallenge (arr) take the array of numbers stored in arr and return the string true if any

two numbers can be multiplied so that the answer is greater than double the sum of all the elements in the array. If not, return the string false. For example: if arr is (2, 5, 6, -6, 16, 2, 3, 6, 5, 3] then the sum of all these elements is 42 and doubling it is 84. There are two elements in the array, 16 * 6 = 96 and 96 is greater than 84, so your program should return the string true. Examples Input: [2, 2, 2, 2, 4, 11 Output: false Input: 11, 1.2, 10, , 1, 121 Outputt true
Computers and Technology
1 answer:
vampirchik [111]3 years ago
6 0

Answer:

The code is given as follows,

Explanation:

Code:

#include <stdio.h>

#include <string.h>  

int n; //to store size of array  

char* ArrayChallenge(int arr[]) //function returns string true or false

{

  int i, j;

  int sum = 0;

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

  {

      sum = sum + arr[i]; //count sum

  }  

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

  {

      for(j = i+1; j < n; j++) //loop for every two elements in array

      {

          if(arr[i]*arr[j] > 2*sum) //check if proudct of two elements > 2 times sum

          {

              printf("\n%d x %d = %d, 2xSum = %d\n", arr[i], arr[j], arr[i]*arr[j], 2*sum);

              return "true"; //If proudct of two elements > 2 times sum. return true

          }

      }

  }

  return "false"; // If proudct of two elements < 2 times sum. return false

}  

int main()

{  

  printf("\nEnter size of array: ");

  scanf("%d", &n); //read size of array

  int A[n]; //array of size n

  printf("\nEnter array elements: ");

  int i;

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

  {

      scanf("%d", &A[i]); //read array from stdin

  }

  printf("%s\n",ArrayChallenge(A)); //ccall function and print answer

 

  return 0;

}

You might be interested in
Jamal likes the theme he has chosen, but he wants to make his presentation more interesting before he saves it. Which command gr
icang [17]

Answer: Variants

Customize

Explanation:

4 0
3 years ago
Read 2 more answers
List all the connectors or components that can be connected internally to the motherboard
Amiraneli [1.4K]

A computer’s motherboard has a series of slots and connectors. Slots allow daughter boards to be plugged directly while connectors allow communication through cables with other peripheral devices. CPU sockets, Hard Drive connectors, Memory sockets, and Power connector are examples of components that can be connected internally in some way to the motherboard. Other physical devices include RAM, hard disks, and graphics card.

5 0
3 years ago
Read 2 more answers
Which of the following choices is not an operating system? A. DOS B. UNIX C. Windows 97 D. Windows Vista
sineoko [7]
It should be A. DOS because all of the others are operating systems.
5 0
3 years ago
Read 2 more answers
What do presentation and word processing software have in common?
Elza [17]
D seems like the best answer because both Microsoft Word and Power Point can do that.

6 0
4 years ago
Read 2 more answers
H. What is recycle bin?<br>-&gt;​
tatyana61 [14]

Answer:

Trash application, the Recycle Bin

6 0
3 years ago
Other questions:
  • Beth’s multimedia business specializes in sound integration and editing. A New project requires video editing and the creation o
    7·1 answer
  • Mihaela I. Croitoru – Utilizarea calculatorului personal Microsoft Word dau coroana
    14·1 answer
  • Describe three perimeter intrusion detection systems and give an example of one that you have seen deployed either at work or an
    8·1 answer
  • True / False<br> An instruction’s opcode generally indicates the number and type of its operands.
    5·1 answer
  • How can the use of new technology in industry benefit the us government
    8·2 answers
  • What is a 96.1791 weighted gpa in a 4.0 scale?
    8·1 answer
  • Code Problem 3 in Python 2.
    5·1 answer
  • Wyatt has a database to keep track of his enormous collection of videos. How can Wyatt find the details for the game Lost on Mar
    11·2 answers
  • Hey guys join me
    9·1 answer
  • What are the risks associated with this kind of connectivity?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!