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
Harrizon [31]
2 years ago
7

Write two statements that each use malloc to allocate an int location for each pointer. Sample output for given program:

Computers and Technology
1 answer:
Mekhanik [1.2K]2 years ago
7 0

Answer:

#include <stdio.h>

#include <stdlib.h>

int main(void) {

   int* numPtr1 = NULL;

   int* numPtr2 = NULL;

   /* Your solution goes here */

   numPtr1 = (int *) malloc(10);

   numPtr2 = (int *) malloc(20);

   *numPtr1 = 44;

   *numPtr2 = 99;

   printf("numPtr1 = %d, numPtr2 = %d\n", *numPtr1, *numPtr2);

   free(numPtr1);

   free(numPtr2);

   return 0;

}

Explanation:

The C library malloc function is used to assign memory locations (in bytes) to variables. It accepts the size parameter and returns a pointer to the specified variable location.

The two malloc statements above assign two memory locations 10 and 20 to the numPtr1 and numPtr2 integer variables respectively.

You might be interested in
Which of the following terms are aspect ratios for devices? 'select all that apply
Viktor [21]

Answer:

1080 x 1920

800 x 600

Explanation:

These are the screen sizes that you can find in the list of the screen sizes, which can be easily found in the document that lists all the screen sizes. You will certainly find the 1080 x 1920 and also the 800 x 600, however, you will not find the 320 x 240 and 800 x 600. The last two are the standard screen sizes and hence are not the correct options. The correct options are as listed above.

3 0
3 years ago
There are two circular grounds Ground-A and Ground-B. Ground-A is having diameter of 15 meters and Ground-B is having diameter o
ExtremeBDS [4]

Answer:

A

Explanation:

b/c the round of 'A' is less than ruond of'B'

4 0
2 years ago
A variable that can be modified from anywhere within a program is called a?
larisa86 [58]
A - a global variable
6 0
2 years ago
An information system interacts with its environment by: A. processing data. B. XML protocols. C. receiving data. D. systems ana
ASHA 777 [7]

Answer:

C. receiving data.

Explanation:

An information system interacts with its environment by receiving data in its raw forms and information in a usable format.

Information system can be defined as a set of components or computer systems, which is used to collect, store, and process data, as well as dissemination of information, knowledge, and distribution of digital products.

Generally, it is an integral part of human life because individuals, organizations, and institutions rely on information systems in order to perform their duties, functions or tasks and to manage their operations effectively. For example, all organizations make use of information systems for supply chain management, process financial accounts, manage their workforce, and as a marketing channels to reach their customers or potential customers.

Additionally, an information system comprises of five (5) main components;

1. Hardware.

2. Software.

3. Database.

4. Human resources.

5. Telecommunications.

<em>Hence, the information system relies on the data it receives from its environment, processes this data into formats that are usable by the end users. </em>

7 0
3 years ago
The open items on your computer are displayed here.
koban [17]
The GUI or Graphical <u /><u></u><em />User Interface.
7 0
2 years ago
Other questions:
  • Software enables users to create documents
    13·1 answer
  • Is the jane austen pride and prejudie a primary source
    6·1 answer
  • A friend was just promoted to a new job that requires part-time travel, and he has also been promised a new laptop after his fir
    10·1 answer
  • How does leadership play a role in IT management? How does leadership need to be aligned to the company’s goals for IT managemen
    9·1 answer
  • Creating Classes
    10·1 answer
  • Suppose that a computer has three types of floating point operations: add, multiply, and divide. By performing optimizations to
    7·1 answer
  • What is intellectual property rights law ?​
    8·1 answer
  • how does a demilitarized zone (dmz) work. A.By preventing a private network from sending malicious traffic to external networks
    10·1 answer
  • If you had tickets for the concert and saw these alerts, what should you do?
    12·1 answer
  • What were the names of Henry VIII's six wives?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!