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
What is often called the brain of a computer
Nookie1986 [14]

Answer:

Explanation:

The computer brain is a microprocessor called the central processing unit (CPU)

6 0
3 years ago
Which of these is NOT an example of lifelong learning?
Sliva [168]

Answer:

Having lunch with a friend

Explanation:

5 0
3 years ago
Select the correct answer.
prisoha [69]

Answer:

I believe it is either, C: Spyware, or D: Worms.

Explanation:

Some Worms can spread on a network, causing bandwidth to be consumed.

8 0
3 years ago
Read 2 more answers
Answer to get brainiest. I NEED HELP PLEASE!! I am supposed to type a program on base conversion. Starts from base of 10 (decima
Virty [35]

Here's a solution that works except for the leading zeros. Unclear (to me) why they need to be there and what's the logic?


  public static void main(String[] args)  

  {    

       int number, base;

       Scanner Cin = new Scanner(System.in);  

       System.out.print("Enter a decimal number between 1 and 100,000: ");

       number = Cin.nextInt();

       System.out.print("Enter a base from 2-16: ");

       base = Cin.nextInt();          

       System.out.format("The number %d in base %d is %s.", number, base, Integer.toString(number, base).toUpperCase());

  }

6 0
3 years ago
Martin just purchased a new computer and wants to surf the web. He is afraid his new computer may get infected by automatically
Kamila [148]

Answer:Martin should get virus protection

Explanation:

if martin has virus protection he won’t get the computer viruses

7 0
2 years ago
Other questions:
  • I'm curious why I would need to know this on a school learning site.
    12·1 answer
  • Use semaphore(s) to solve the following problem. There are three processes: P1, P2, and P3. Each process Pi has a segment of cod
    11·1 answer
  • Internet control message protocol (icmp) is a method of ip address assignment that uses an alternate, public ip address to hide
    7·1 answer
  • My home PC has IP address 192.168.1.22 and connects to the Internet through a NAT router. Assume I am downloading a web page fro
    5·1 answer
  • blank affect your vision because your eye muscles are tired along with the rest of your body and is difficult to focus
    11·2 answers
  • Why are computer messages encapsulated?
    13·1 answer
  • Which file types have .exe and .omg as their extensions?
    15·1 answer
  • Create a database with information about products in a catalog. As you plan, keep in mind that later you will want to sort this
    10·2 answers
  • As a general rule, what is the size of a brochure?
    11·1 answer
  • In which generation microprocessor was developed short answer of computer science​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!