Untitled

 avatar
unknown
plain_text
a year ago
577 B
8
Indexable
#include<iostream>
using namespace std;

class calculation {
private:
    int arr[100];
    int sum=0,product=1;

public:
    void get_input(int n) {

    for(int i = 0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
        product*=arr[i];}

    }
    void display() {
    cout<<"The Sum of the Array Element is: "<<sum<<endl;
    cout<<"The Product of the Array Element is: "<<product<<endl;

    }

};

int main() {
 calculation myarray;
 cout<<"Enter Array Size:"<<endl;
 int n;
 cin>>n;
 myarray.get_input(n);
 myarray.display();

}
Editor is loading...
Leave a Comment