1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
makvit [3.9K]
3 years ago
15

Given the variable ip, already declared as a pointer to an integer, write the code to dynamically allocate memory for a single i

nteger value, assign the resulting pointer to ip, and initialize the integer value to 27.
Computers and Technology
1 answer:
stepan [7]3 years ago
8 0

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.

You might be interested in
Can someone please help me with this ,it is my assignment of technology and agriculture year 8
zmey [24]

Answer:

?????????/?????????

Explanation:

5 0
2 years ago
What is the keyboard shortcut to display the merge to printer dialog box?
sp2606 [1]
Alt + Shift + M are the keyboard shortcuts to display the merge to printer dialog box.
3 0
3 years ago
The ________ contains the central electronic components of the computer. select one:
Sati [7]
The motherboard contains the central electronic components of the computer.
6 0
2 years ago
A security administrator is required to submit a new csr to a ca. what is the first step?
m_a_m_a [10]
If an administrator needs to renew a certificate for a web server he/she should submit the CSR (Certificate Signing Request) to CA.
<span>If a security administrator is required to submit a new CSR to a CA, teh fisrt step the administrator should do is to g</span>enerate a new private key based on RSA.
4 0
3 years ago
A​ _______ helps us understand the nature of the distribution of a data set.
Sphinxa [80]

Frequency distribution
3 0
2 years ago
Other questions:
  • Which of the following accurately completes this sentence? The Internet is ____.
    6·2 answers
  • Janice has a "jammed" key on her keyboard. Every time she strikes the "S" key it sticks and doesn't pop back. What should Janice
    6·2 answers
  • In this exercise, you are given a phrase and need to return that phrase in all capital letters.
    6·1 answer
  • Please answer this a due tomorrow!!!
    5·1 answer
  • What is the purpose of the domain name​
    5·1 answer
  • You are asked to monitor a network which has a network monitoring system. Using the monitoring server, you notice that it is lis
    13·1 answer
  • So I was looking at my profile and it says i'm a brainly PLUS member didn't sign up for it tho. Any ideas why this could have ha
    14·2 answers
  • Pls help will give brainlest​
    15·2 answers
  • Make a list of five primary raw materials, for each one, indicate and industrial material that is created from it
    10·2 answers
  • What is a benefit of an account with interest?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!