Preview:
#include <iostream>
using namespace std;

int main()
{
    int *p;
    p= (int *)malloc(5*sizeof(int));  
    //will allocate memory for 5 integers, so it is an array of integers and it is assigned to p
    
    //initializing the values
    p[0] = 10;
    p[1] = 20;
    p[2] = 30;
    p[3] = 40;
    p[4] = 50;

    
    for(int i=0; i<5; i++)
    {
        cout << p[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