Computer Science, asked by 2022411054, 6 hours ago

Write a C++ function which accepts an array of integers and the size of the array and finds :
a. Sum of the elements in the array
b. Average of the array elements
c. Minimum and maximum values in the array
In the main program, declare an array of 7 integers using dynamic memory allocation and call
the aforementioned function. Display the output of the function within the main.

Answers

Answered by prantikchinchkar2007
0

Answer:

gshsjsjdjjdjejdhehedjsjjejendndh

Answered by shilpa85475
0

a. Sum of the elements in the array

b. Average of the array elements

c. Minimum and maximum values in the array

Explanation:

class abc

{

  public static void main(String args[])

{

     int[] array = {10, 20, 30, 40, 50, 10};

     int sum = 0;

int max = 0; int min=0;

     //Advanced for loop

     for( int num : array) {

         sum = sum+num;

     }

     System.out.println("Sum of array elements is:"+sum);

  }

for(int i = 0; i < n ; i++)

       {

           a[i] = s.nextInt();

           int sum1 = sum1 + a[i];

       }

       System.out.println("Sum:"+sum1);

       average = (float)sum / n;

       System.out.println("Average:"+average);

for(int i=0; i<array.length; i++ )

{

        if(array[i]>max) {

           max = array[i];

        }

System.out.println("Maximum of array", +max);

for(int i=0; i<array.length; i++ )

{

        if(array[i]<min) {

           min = array[i];

System.out.println("Minimum of array", +min);

}

Similar questions