This program creates an integer pointer p and dynamically allocates an array of 5 integers using the new operator. The second element of the array is then assigned the value 20 and printed using cout. The delete[] operator is used to free the memory allocated by new, and the pointer p is set to nullptr.
#include<iostream> using namespace std; int main() { int *p=new int[5]; p[0]=10; p[1]=20; cout <<p[1]<<endl; delete []p; p=nullptr; return 0; }To download raw file Click Here
20
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions