Dynamically Allocating Arrays Depending on User Input in c++

This video tutorial explains how to allocate an array dynamically using new and delete operators.
check out what is dynamic memory allocation and what is the need of it at

In this tutororial you will learn how to allocate arrays dynamically,how to allocate memory dynamically depending on users input,how to access dynamically allocated memory,how to use pointers with dynamically allocated memory in detail with example.

source code for this tutorial

#include <iostream>

using namespace std;

int main()
    int *pointer = nullptr;
    cout << "how many items u are gonna enter"<<endl;
    int input;
    cin >> input;

    pointer = new int[input];

    int temp;

    for(int counter =0; counter < input ; counter++){
        cout << "enter the item "<<counter+1<<endl;
        cin >> temp;
        *(pointer+counter) =  temp;

    cout << "the items you have entered are"<<endl;
        for(int counter =0; counter < input ; counter++){
        cout << counter+1 << "  item is  "<<*(pointer+counter)<<endl;


    delete []pointer;

    return 0;