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
Differences between iphone 6 and 6s
amid [387]
I phone 6s is bigger than a regular iphone and iphone 6s's dosn't bend like iphone 6
4 0
4 years ago
1. Open the start file EX2019-ChallengeYourself-9-3. The file will be renamed automatically to include your name. Change the pro
lara [203]

Answer:

Omg what is this

soooo long questionn

i am fainted

7 0
3 years ago
Read 2 more answers
Chris has received an email that was entirely written using capitalization. He needs to paste this text into another document bu
dem82 [27]

Select the text you want to alter.

Press Shift+F3. Word changes the case of the selected text.

Continue pressing Shift+F3 until the case is the way you want it.

hope this helps

8 0
3 years ago
Read 2 more answers
What company or individual is responsible for developing the linux operating system?
Arisa [49]
The guy is Linus Torvalds.,
If this was helpful, please mark me as brainliest.
3 0
4 years ago
Careers on the largest declining industries list will see an increase in the number of employees in their workforce.
IrinaK [193]

The answer is False.

The word "declining" means going down. So, in this case, the employees would go down or leave.

7 0
3 years ago
Other questions:
  • Which expansion slot is used by an NVMe compliant device?
    9·1 answer
  • Controls that are used to assess whether anything went wrong, such as unauthorized access attempts, are called ________ controls
    5·2 answers
  • Write a method named lastFirst that accepts a string as its parameter representing a person's first and last name. The method sh
    13·1 answer
  • Which vpn protocol is a poor choice for high-performance networks with many hosts due to vulnerabilities in ms-chap?
    15·1 answer
  • The most common types of utility programs fall into these categories. accessibility calculation communication data entry enterta
    6·2 answers
  • In Microsoft Access, what happens when you save a query once and run it but then add more to the query? What will happen? a)erro
    12·1 answer
  • Gwen's company is planning to accept credit cards over the Internet. Which one of the following governs this type of activity an
    13·1 answer
  • Juan copied and pasted information from a Word document
    8·1 answer
  • Which formatting option(s) can be set for conditional formatting rules?
    9·1 answer
  • What kind of charger can i use for this
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!