Answer:
In C++:
int *ip;
ip = new int;
*ip = 27;
Explanation:
First of all, let us have a look at the methods of memory allocation to a variable.
1. Compile Time: The memory gets allocated to the variable at the time of compilation of code only. It is also called <em>static </em>allocation of memory.
Code example:
int a = 5;
2. Run Time: The memory is allocated to the variable <em>on the fly </em>i.e. during the execution of the program. It is also called <em>dynamic </em>allocation of memory.
Now, we have to write code for a variable ip, which is an integer pointer to dynamically allocate memory for a single integer value and then initialize the integer value 27 to it.
Initializing a variable means assigning a value to variable for the first time.
Writing the code in C++ programming language:
<em>int *ip;</em> // Declaring the variable ip as a pointer to an integer
<em>ip = new int;</em> // Dynamically allocating memory for a single integer value
<em>*ip = 27; </em> // Initializing the integer value to 27.