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]
3 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]3 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
Peter is a data analyst in a financial firm. He maintains a spreadsheet that contains all employee details. Peter wants to analy
alukav5142 [94]

Answer: filter the data of employees with more than five years of experience

Explanation:

The technique that Peter can use to perform this analysis is to filter the data of employees with more than five years of experience.

Filter in spreadsheets allows one to see the data that is required based on the input that was given. In this case, since Peter wants to analyze the data of all employees that have experience of more than five years, this can be filtered and the employees who have experience of more than 5 years will be shown.

The workers who have experience of less than five years will not b shown in this case.

3 0
3 years ago
Which of the following is NOT an argument used to determine how a shot is fired from an A. object the shot itself being instanti
Firdavs [7]
C. The color of the shot...
7 0
3 years ago
A time line may identify cause or effect of an event?<br> True or False?
levacccp [35]
True whenever you look at one it helps identify the cause/effect of an event
3 0
3 years ago
"A web server must be accessible to untrusted outside users. What can be done to isolate this host and any additional hosts with
Olegator [25]

Answer:

C.

Explanation:

Based on the information provided within the question it can be said that the best thing to do in order to accomplish this would be to create a DMZ and add all the necessary hosts to it. A DMZ or demilitarized zone is a feature that allows those on the list to bypass all security features and have access to the organization's external-facing services.

4 0
3 years ago
Write an If . . . Then statement that tests whether the value in the variable intRow is between 1 and 8. If the number is in tha
____ [38]

Answer:

The statement to this question can be described as follows:

Statement:

if (intRow > = 1 && intRow < = 8)

{

lblCabin.Text= “First Class"; //if block that checks the given range and assign the value.

}

Explanation:

Description of the if block:

  • In the above, If statement fist the value is check, that is it is in the range or not.
  • To check its value an "intRow" variable is used, that checks the value is greater than equal to 1 and less than equal to 8, in between both condition AND operator, that executes when both conditions are true.
  • Inside the if block a label "lblCabin" is used that assigns a value that is "First Class".
7 0
3 years ago
Other questions:
  • Which of the following menu commands would you select to make a copy of an open file and rename it
    14·2 answers
  • Explain one way world war ii?-era advances in computers
    11·1 answer
  • In Windows applications, a ____ control is commonly used to perform an immediate action when clicked.a. text boxb. buttonc. wind
    7·1 answer
  • ____________ signs, as discussed by Charles Peirce, involve an "existential" relationship between the sign and the interpretant.
    6·1 answer
  • Write a program that reads three numbers and print the largest one step by step answer
    9·1 answer
  • Where do charts get the data series names?
    14·1 answer
  • What do you understand by storage devices ? Name any two storage devices.​
    11·2 answers
  • В.
    11·1 answer
  • Задание: Построить иерархию классов в соответствии с вариантом задания. Построить диаграммы классов.
    8·1 answer
  • Write an if-else statement that assigns 0 to the variable b if the variable a is less than 10. Otherwise, it should assign 99 to
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!