#include<iostream.h>
#include<conio.h>
class vector
{
private:
                int sz;
                int *v;
public:
                void vectorsize(int size)
                {
                                sz=size;
                                v=new int[size];
                }
                void read();
                void show_sum();
                void release()
                {
                                delete v;
                }
};
void vector::read()
{
                int i;
                for(i=0;i<sz;i++)
                                {
                                cout<<"Enter Element:- ";
                                cin>>v[i];
                                }
}
void vector::show_sum()
{
                int i,sum=0;
                for(i=0;i<sz;i++)
                sum+=v[i];
                cout<<"Sum of element:- "<<sum<<endl;
}
void main()
{
                int count;
                vector v;
                clrscr();
                cout<<"Enter size:- ";
                cin>>count;
                v.vectorsize(count);
                v.read();
                v.show_sum();
                v.release();
                getch();
}
Advertisements