#include <iostream>

using namespace std;

int main()
{
	//Pointers and Addresses
    int num = 100;
    int *ptr;
    ptr = &num; //ptr is set to the address of num
    
    cout << ptr << endl; 
    cout << *ptr << endl << endl; // Dereferencing
    cout << &num << endl; 
    cout << num << endl << endl;
    
    //Dynamic Variables
    int *ptr2;
    int num2 = 50;
    ptr2 = new int;
    *ptr2 = num2; // Dereference and set it equal to the value of num 2
    cout << num2 << endl;
    cout << *ptr2 << endl << endl; // Dereferencing
    
    // Dynamic Array
    int *array;
    array = new int[4];
    for(int i = 0; i < 4; i++)
    {
        cout << "Put in integers: ";
        cin >> array[i];
    }
    for(int i = 0; i < 4; i++)
    {
        if(i==3)
            cout << array[i] << endl;
        else
            cout << array[i] << ", ";
    }
    
    delete ptr2;
    delete []array;
    
    return 0;
}