Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void main()
- {
- cout<<"DYNAMIC MEMORY WORK"<<endl;
- cout<<"Creating variables."<<endl;
- int *a = new int;
- int *b = new int;
- int *c = new int;
- cout<<endl<<"Enter a: ";
- cin>> *a;
- cout<<endl<<"Enter b: ";
- cin>> *b;
- cout<<endl<<"Enter c: ";
- cin>> *c;
- cout<<"a + b = "<<*a+*b<<endl;
- cout<<"a + c = "<<*a+*c<<endl;
- delete a, b, c;
- cout<<endl<<"Creating an array of arbitary size."<<endl;
- int *d = new int;
- cout<<"Set an array size: ";
- cin>>*d;
- int *arr = new int [*d];
- for (int i = 0; i<*d; i++)
- {
- cout<<"Inter the "<<i+1<<" member of array: ";
- cin>>arr[i];
- }
- cout<<"The array is:";
- for (int i = 0; i<*d; i++)
- cout<<" "<<arr[i];
- cout<<endl;
- delete arr;
- delete d;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement