Preview:
#include <iostream>
using namespace std;

int fun(int size)
{
  int *p;
  p = new int[size];
  
  for(int i=0; i<size; i++)
    p[i]=i+1;
  return p;
}

int main()
{
  int *ptr, sz = 5;
  ptr = fun(sz);
  
  for(int i=0;i<sz;i++)
    cout << ptr[i]<<endl;
  
  return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter