Professional Documents
Culture Documents
STUDENT'S NAME - Balwinder Singh Kalsi Student'S Uid - 21Bcs1679 Class and Group - 204 A Semester - 1
STUDENT'S NAME - Balwinder Singh Kalsi Student'S Uid - 21Bcs1679 Class and Group - 204 A Semester - 1
1
STUDENT’S NAME –Balwinder Singh Kalsi
STUDENT’S UID – 21BCS1679
CLASS AND GROUP – 204 A
SEMESTER –1
PROGRAM CODE
#include <iostream>
using namespace std;
int main()
{
int size ,i;
int sum=0;
int *ptr;
cout<<"Enter the number of students";
cin>>size;
ptr=new int[size];
for(i=0;i<size;i++)
{
cout<<"Enter Marks";
cin>>ptr[i];
}
for (i=0;i<size;i++)
{
cout<<"Enter marks are"<<endl;
cout<<ptr[i]<<"\n";
}
for(i=0;i<size;i++)
{
sum=sum+ptr[i];
SUBJECT NAME- OBJECT ORIENTED PROGRAMMING
USING C++ LAB
SUBJECT CODE-CSP-152
}
delete[]ptr;
}
In this program we have studied how to allocate the memory and delete the
memory without using class.
OUTPUT
PROGRAM CODE
#include <iostream>
using namespace std;
class stud {
public:
stud()
{
cout << "Constructor Used" << endl;
}
~stud()
{
cout << "Destructor Used" << endl;
}
};
int main()
{
stud* S = new stud[6];
delete[] S;
}