Computer Science, asked by at9738122, 18 days ago

Define a class to declare an array of size 20 of double data type, accept the element into the array d perform the following :
● calculate and print the sum of all the elements.
● calculate and print the highest value of the array.

Answers

Answered by ashishbisht246800
1

Answer:

The C++ program for the given question is,

#include<iostream>

using namespace std;

class some{

  double arr[20];

public:

  void init(){

      cout<<"Start entering the elements ::::::\n";

      for(int i=0;i<20;i++){

          cout<<"\t";

          cin>>arr[i];

      }

  }

  void sum();

  void high();

};

void some::sum(){

  int sum_all;

  for(int i=0;i<20;i++){

          sum_all+=arr[i];

  }

  cout<<"\nThe sum of all the elements is "<<sum_all;

}

void some::high(){

  int maximum = arr[0];

  for(int i=1;i<20;i++){

          if(arr[i] > maximum)

              maximum = arr[i];

  }

  cout<<"\nHighest value of the array is "<<maximum;

}

int main(){

  some object;

  object.init();

  object.sum();

  object.high();

  return 0;

Explanation:

HOPE YOU LIKE THE ANSWER

Answered by 21e010059
0

Answer:

) Create a temporary array of size (k-1) to store elements and their counts (The output elements are going to be among these k-1 elements). Following is structure of temporary array elements. struct eleCount {

   int element;

   int count;

};  

struct eleCount temp[];

Explanation:

Similar questions