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
Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 or 95) go north/south, and events (like the 10 or 90
Norma-Jean [14]

Answer:

The C code for the problem is given below

Explanation:

#include <stdio.h>

int main() {

   int highwayNumber;

   int primaryNumber;

   scanf("%d", &highwayNumber);

   if (highwayNumber >= 1 && highwayNumber <= 999) {

       if (highwayNumber <= 99) {

           if (highwayNumber % 2 == 0) {

               printf("I-%d is primary, going east/west.\n", highwayNumber);

           } else {

               printf("I-%d is primary, going north/south.\n", highwayNumber);

           }

       } else {

           primaryNumber = highwayNumber;

           highwayNumber %= 100;

           if (highwayNumber % 2 == 0) {

               printf("I-%d is auxiliary, serving the I-%d, going east/west.\n", primaryNumber, highwayNumber);

           } else {

               printf("I-%d is auxiliary, serving the I-%d, going north/south.\n", primaryNumber, highwayNumber);

           }

       }

   } else {

       printf("%d is not a valid interstate highway number.\n", highwayNumber);

   }

   return 0;

}

4 0
2 years ago
Read 2 more answers
Drag each label to the correct location. Each label can be used more than once. Match the device to the port through which it co
son4ous [18]

Answer:

Mouse - USB

Monitor - display port, HDMI, and thunderbolt port

External hard drive - USB and thunderbolt port

Flash drive - USB

Explanation:

A computer mouse is an input device used to interact with a computer system. It connects with the computer through the USB port.

A Monitor is an output device that is used to display information on a computer system. It can be connected to the system through the display ports, HDMI, and the thunder port.

The External hard drive is a storage device that holds data for a long period of time. It has adapters to connect to the computer through the USB ports or thunderbolt ports. The flash drive is similar in function to the hard drive but small in size and storage space. It only connects with the computer through USB ports.

5 0
2 years ago
an early type of GUI is created, which includes windows, pop-ups, icons, and menus. What year did this happen? Please help!!! qu
Dahasolnce [82]

Answer:

1979

Sources:

Wired

InventHelp

hope i helped :D

3 0
3 years ago
Anyone Free to Talk??????? I'm Bored :(
Ahat [919]

Answer:

sure

Explanation:

wssp

4 0
3 years ago
Read 2 more answers
What are three ways that functions can be useful when you are writing programs
grin007 [14]

Answer:

Reduces the overall complexity of your program

Allows you to easily call a function from different parts of your program after defining it.

Helps break a problem into logical chunks

Explanation:

5 0
2 years ago
Other questions:
  • which of the following are used on cable trays to protect the cable insulation from direct sunlight? a. barrier strips b. solid
    5·1 answer
  • How do i protect my computer from electrical spikes
    14·2 answers
  • There are a multitude of items that Cyber Security professionals view as attack vectors but none are more prevalent and exploita
    13·1 answer
  • Computer design replaced ______________
    14·1 answer
  • Timothy was reading tournament results of the football World Cup matches on Infogoalistic.com. As he was going through the resul
    14·1 answer
  • American company Software Unlimited is planning to expand its operations to the Bangor Republic where the group is the primary u
    7·1 answer
  • Hank is the network administrator responsible for managing the web server cluster for an e-commerce company. He’s worried about
    9·1 answer
  • Which of the following is based on the visibility and location of an object’s features?
    15·1 answer
  • Why would you browse by entering a URL rather than use a link in a Web page
    15·1 answer
  • Discuss new concepts that you have learned about Cisco Devices and how they will be helpful in the workplace.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!