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
To remove an embedded chart, you should _____ it and press the DELETE key.
choli [55]
Place the mouse cursor over the chart's border. Do not place it within the chart; this may select individual chart elements, such as the legend box or headings. Click the mouse. Excel will select the chart, surrounding it with a thicker, light grey border. Then press delete or backspace. Hope this helped. :)
3 0
3 years ago
Read 2 more answers
Please help me i’ll give you brainlist
Genrish500 [490]

answer: C

explanation: because it's the biggest of the given platforms

5 0
2 years ago
What does the acronym GIF stand for? Graphics Interface Format Graphics Interchange Format Going Into Files Gathering Informatio
Anna35 [415]
Graphics Interchange Format! :)
4 0
3 years ago
Read 2 more answers
Who here has an old (preferably 80s) Toyota Celica i just bought mine and want to know how you guys like yours because mine is f
Maurinko [17]

Answer:

Explanation:

The 1980 Toyota Celica is a great car, it was my first car and I loved it. It has many luxury features that you don't see much in cars of that year. It is also extremely reliable and can take lots of use before beginning to give problems. I used to use it to get to and from school on a daily basis and it never once left me stranded. It includes power steering, cruise control, AC, etc. Not much more you can ask for in a car, it is also a very beautiful looking car, especially a well taken care of one. Enjoy your car.

8 0
3 years ago
What are the pros and cons of using ICT​
Setler79 [48]

Answer:

Communication - Speed / time – money can be saved because it's much quicker to move information around. ...

Globalization - Video conferencing saves money on flights and accommodation. ...

Cost effectiveness - It feels free to send an email (although it isn't); it's without doubt cheaper than phone calls.

Explanation:

4 0
3 years ago
Other questions:
  • In most software packages, the function key F1 is used to run the _____program.
    10·1 answer
  • Characters used to control the position of the output on the screen or paper, to cause some action to occur, such as ringing a b
    10·1 answer
  • Define Indentation
    8·1 answer
  • What is the disadvantage of server based network?
    7·2 answers
  • Please help if you answer correcly i will give you brainelst!!!!!!!!!!!!!!!!!!
    6·2 answers
  • A swimming pool has a length of 28 feet, a width of 17 feet, and a depth of 6 feet. How much water can the swimming pool hold?
    10·1 answer
  • Employing the use of a(n) <br> will help you manage a STEM project.
    13·1 answer
  • The Ocean Medallion is a wearable device that connects virtually to various devices on board a cruise ship. When a guest is wear
    14·1 answer
  • Pls paanswer asap......​
    10·1 answer
  • In cell b12 create a formula using max f7nction to calculate maximum value in B4:B9
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!