Wipro Elite Coding Problem #4 | Maximum Energy in Science Lab

Today we are going to discuss some Wipro Elite Coding Questions that has been asked in previous years in Wipro for Project Engineer role for Freshers.

So, If you are appearing in Wipro Elite, then there are fair chances that you can get same difficulty level of questions in your actual exam.

Wipro elite coding problem 4

Hi all, Welcome to Jobs Adda. Here you would get all fresher jobs updates and placement material for engineering graduates related to IT/Core sector.

To get all job updates on time, Don’t forget to join our whatsapp group. Click below to join.


In a science research lab, combining two nuclear chemicals produces a maximum energy that is the product of the energy of the two chemicals. The energy values of the chemicals can be negative or positive. The scientist wishes to calculate the sum of the maximized energies of the two elements when the reaction happens. Write an algorithm to find the total energy produced by the chemicals when the reaction happens.

Input
The first line of the input consists of an integer numOfChem, representing the number of chemicals (N). The second line consists of N space-separated integers – enerp ener2, , enerN representing the energies of the chemicals.

Output
Print an integer representing the total energy produced by the chemicals when the reaction happens.

Constraints
0 <_ num0fChem 106
-106<ener<106
0 < i<numOfChem

Example

Input:
7
9-3 8-6-7 8 10

Output:
19

Explanation:
NA

Solution: In C

#include <stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int i,e[n];
    for(i=0;i<n;i++)
        scanf("%d",&e[i]);
    int j,t;
    for(i=0;i<n-1;i++)
    {
        for(j=0;j<n-1-i;j++)
        {
            if(e[j]<e[j+1])
            {
                t=e[j];
                e[j]=e[j+1];
                e[j+1]=t;
            }
        }
    }
    printf("%d",e[0]+e[1]);
}

Leave a Reply

Your email address will not be published. Required fields are marked *