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
2. ¿Cuáles de los siguientes Software son lenguajes de Programación?
poizon [28]

B) C# Java y Visual Basic

6 0
3 years ago
As a ______________ you must be able to show that you know what to do to keep food safe
Natali [406]

         

<h2>\beta\beta \beta \geq \neq</h2>
6 0
3 years ago
Press the _______ key to move to the next cell in a row.
slamgirl [31]

Tab is the answer! And it says i need 20 chacters to explain so im writing random stuffff



4 0
3 years ago
Emily is an aspiring lyricist. She wants to make a demo tape to send to recording companies. Which input device can she use to r
satela [25.4K]
She would use a microphone. A joystick and mouse are two answers we could eliminate immediately. Seeing as she is an aspiring lyricist means she is in the music industry, so she wold need to use a microphone to be able to record.  
6 0
3 years ago
Renee works for a television series. Her responsibility is to transfer data from the camera to a hard drive. What is her job des
Marysya12 [62]

Answer:

Data wrangler

Explanation:

Her responsibility is to transfer data from the camera to a hard drive. What is her job designation? Data Wrangler.

<h2>mark as brainliests </h2>
8 0
2 years ago
Other questions:
  • If a security officer is non-commissioned officer, he can carry a baton on duty if he went through a training class
    8·1 answer
  • At the beginning of this month, the balance of Reed's checking account was $692.35. So far this month, he has received a paychec
    13·2 answers
  • Which is most harmful computer virus define​
    15·1 answer
  • _____the measuring instrument is not necssery​
    10·1 answer
  • Match the following.
    8·1 answer
  • PLS PAK I ANSWER NITO KAILANGAN LANGPO​
    6·1 answer
  • Write a program that accepts a whole number as input, multiplies that number by 12, and then outputs the product.
    6·2 answers
  • What is the output for the following program?
    6·2 answers
  • True or false: if you are adding your own css sheet, make sure your css file comes before the bootstrap css file.
    7·1 answer
  • Edit the following statement so it uses the constant named YEAR:
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!