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
Which term collectively discribes hard disk ,CD,and flash drives​
mixer [17]

Answer:

The term memory collectively describes hard disk, CD and flash drive

Explanation:

4 0
3 years ago
Read 2 more answers
5.11 Of these two types of programs:a. I/O-boundb. CPU-boundwhich is more likely to have voluntary context switches, and which i
Leno4ka [110]

Answer:

The answer is "both voluntary and non-voluntary context switch".

Explanation:

The description to this question can be described as follows:

Whenever processing requires resource for participant contextual switch, it is used if it is more in the situation of I/O tied. In which semi-voluntary background change can be used when time slice ends or even when processes of greater priority enter.

  • In option a, It requires voluntary context switches in I /O bound.
  • In option b, it requires a non-voluntary context switch for CPU bound.
7 0
4 years ago
The program 4 should first tell users that this is a word analysis file. For any user-given text file, the program will read, an
djverab [1.8K]

Answer:

See explaination

Explanation:

import os,string

def readfile(filename):

if os.path.isfile(filename) is not True:return None

line_number=1

word_dict={}

print('Text File to be analyzed: {}'.format(filename))

with open(filename,'r') as infile:

for line in infile.readlines():

words = line.strip().split()

for word in words:

word = word.strip(string.punctuation)

if word.strip()=='':continue

if word_dict.get(word)==None:

word_dict[word]=[line_number]

else:

line_number_list=word_dict.get(word)

line_number_list.append(line_number)

line_number+=1

return word_dict

def write_to_file(word_dict,filename):

with open(filename,'w') as outfile:

for word in sorted(word_dict.keys()):

outfile.write('{0}:\t\t{1}\n'.format(word,','.join([str(n) for n in word_dict.get(word)])))

def main():

filename='D:\\Word.txt'

output_filename='D:\\word_index.txt'

word_dict = readfile(filename)

if word_dict ==None:

print('Unable to read file {}'.format(filename))

else:

for word in sorted(word_dict.keys()):

print('{0}:\t\t{1}'.format(word,','.join([str(n) for n in word_dict.get(word)])))

write_to_file(word_dict,output_filename)

main()

7 0
3 years ago
________ databases are the most commonly used electronic databases. multidimensional object-oriented relational flat-file
Maurinko [17]
O
I would say a SQL database
3 0
3 years ago
6. An example of a private network is.<br> •internet<br> •wi-fi<br> •modem<br> •router
kaheart [24]

Answer:

a. internet

because all the others are public

7 0
3 years ago
Read 2 more answers
Other questions:
  • Which two technologies support the building of single-page applications?
    11·1 answer
  • What is a URN (include example)
    13·1 answer
  • The size of an array (how many elements it contains), which is accessed by .Lenth() returns (Choose the best answer)
    5·1 answer
  • Write a C++ nested for loop code to print out the following onthe screen1 2 3 4 5 67 8 91 2 3 4 5 67 81 2 3 4 5 671 2 3 4 561 2
    11·1 answer
  • Why is information so important?
    6·2 answers
  • What is a non-example of job outlook.
    7·1 answer
  • Given N lines of input, print the 3rd character from each line as a new line of output. It is guaranteed that each of the n line
    8·1 answer
  • Which of these is an example of collective voice?
    8·2 answers
  • A device which is not connected to the cpu is known as?​
    12·1 answer
  • Fern has set up a computer network for the entire building. Unfortunately, the signal strength diminishes as it reaches toward t
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!