6.6k views
0 votes
Write a program that accepts each element in the array from the user, and finds the following:

a. The minimum number in the array
b. The maximum number in the array
c. Average of all values in the array
d. Sum of the numbers present from index [2] to index [7]
e. Identify how many times ‘5’ was found in the array.
f. Identify all the odd numbers in the array
g. Sum of all odd numbers in the array
h. Identify even numbers in the array
i. Sum of all even numbers in the array
j. Identify count of even numbers and odd numbers in the array.
k. Identify numbers which are divisible by 2 and 5.

User Goodlife
by
4.8k points

1 Answer

2 votes

Answer:

Find four elements a, b, c and d in an array such that a+b = c+d

Given an array of distinct integers, find if there are two pairs (a, b) and (c, d) such that a+b = c+d, and a, b, c and d are distinct elements. If there are multiple answers, then print any of them.

Example:

Input: {3, 4, 7, 1, 2, 9, 8}

Output: (3, 8) and (4, 7)

Explanation: 3+8 = 4+7

Input: {3, 4, 7, 1, 12, 9};

Output: (4, 12) and (7, 9)

Explanation: 4+12 = 7+9

Input: {65, 30, 7, 90, 1, 9, 8};

Output: No pairs found

Expected Time Complexity: O(n2)

Step-by-step explanation:

I hope this helps u

have a nice day

User Blayzeing
by
5.2k points