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