Computer Science, asked by ghoshdebabrata2004, 8 months ago

Write java program
Write a program to find from the following data: 17, 20, 24, 29, 16, 87, 19, 52

a) The largest and smallest element b) Product of the odd numbers c) sum of the even numbers​

Answers

Answered by rajansharma46
9

Answer:

public class ques15

{

public static void main()

{

int i;

int a[] = {17,20,24,29,16,87,19,52};

int max = a[0],min = a[0],oddSum = 0,evenSum = 0;

for(i = 0;i<8;i++)

{

if(a[i]%2 = = 0)

evenSum+ = a[i];

if(a[i]%2 = = 1)

oddSum+ = a[i];

if(a[i]>max)

max = a[i];

if(a[i]<min)

min = a[i];

}

System.out.println ("Sum of Odd nos = "+oddSum);

System.out.println ("Sum of Even nos = "+evenSum);

System.out.println ("Maximum = "+max);

System.out.println ("Minimum = "+min);

}

}

Similar questions