Computer Science, asked by poojavema0922, 1 day ago

consider an array of non zero postive integers inarr and a number innum where the elements of inarr and innum would be greater than 1.identify and print a 2d array outarr based on the logic given.​

Answers

Answered by Anonymous
0

array of non zero postive integers inarr and a number innum where the elements of inarr and innum would be greater than 1.identify and print a 2d array outarr based on the logic given.

Answered by ishwaryam062001
0

Answer:

Python program - The final outarr is returned as the result of the function.

Explanation:

From the above question,

They have given :

This code takes two inputs, inarr, an array of non-zero positive integers, and innum, a number. It iterates over the elements of inarr, and for each element, it checks if it can be combined with another element in the array to give innum. If it finds such elements, it adds them to a temporary array temp, and then adds temp to the final output array outarr. The final outarr is returned as the result of the function.

Example,

      The input inarr is [2, 3, 5, 7, 11, 13] and innum is 65.

      The output outarr would be [[5, 13]] as 5 * 13 = 65.

                                         PROGRAM

def identify_array(inarr, innum):

   outarr = []

   for i in range(len(inarr)):

       temp = []

       for j in range(len(inarr)):

           if inarr[i] * inarr[j] == innum:

               temp.append(inarr[i])

               temp.append(inarr[j])

               outarr.append(temp)

               break

   return outarr

inarr = [2, 3, 5, 7, 11, 13]

innum = 65

outarr = identify_array(inarr, innum)

print(outarr)

For more such related questions : https://brainly.in/question/53535976

#SPJ3

Similar questions