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
pav-90 [236]
3 years ago
12

Write the half function. A function call and the functionprototype

Computers and Technology
1 answer:
EastWind [94]3 years ago
3 0

Answer:

C code for half()

#include<stdio.h>

void half(float *pv);

int main()

{

float value=5.0;  //value is initialized  

printf ("Value before half: %4.1f\n", value); // Prints 5.0

half(&value);  // the function call takes the address of the variable.

printf("Value after half: %4.1f\n", value); // Prints 2.5

}

void half(float *pv) //In function definition pointer pv will hold the address of variable passed.

{

*pv=*pv/2;  //pointer value is accessed through * operator.

}

  • This method is called call-by-reference method.
  • Here when we call a function, we pass the address of the variable instead of passing the value of the variable.
  • The address of “value” is passed from the “half” function within main(), then in called “half” function we store the address in float pointer ‘pv.’ Now inside the half(),  we can manipulate the value pointed by pointer ‘pv’. That will reflect in the main().
  • Inside half() we write *pv=*pv/2, which means the value of variable pointed by ‘pv’ will be the half of its value, so after returning from half function value of variable “value” inside main will be 2.5.

Output:

Output is given as image.

You might be interested in
Create a horizontal line across middle of the entire form. To code this the ____ values are the same.
fredd [130]

To make a horizontal line in mathematics you require some sort of constant function. Where no matter the input x the output y will always equal to a certain number n.

For eg. consider n = 2. Hence the graph of line has an equation of y = n making it always intercept in (x, n). As x increases the y is the same therefore the horizontal infinite line emerges.

So to plot or code this kind of program you need to have the same values of y therefore y is a constant function.

Hope this helps.

r3t40

5 0
3 years ago
Read 2 more answers
Sorting and filtering are two ways to blank data
madreJ [45]
It’s two ways to analyze data
6 0
3 years ago
The envelope method, notebook and pencil, and online software are all methods of ______.
coldgirl [10]

Answer:

communication

Explanation:

5 0
2 years ago
Read 2 more answers
A programmer is responsible for solving a problem and making a presentation that includes his solution. He does not have much ro
sashaice [31]

Probably 2 but that's just a guess.


5 0
2 years ago
Read 2 more answers
A major weakness of a lot of file processing systems is that ____.
Gnesinka [82]

They are several weaknesses or disadvantages of file processing systems but the major weakness is data redundancy and inconsistency. By data redundancy, I mean duplication of data. There are no better methods to validate insertion of duplicate data in file systems. Data redundancy can also increase the chance for errors.






7 0
3 years ago
Other questions:
  • You use different office apps to accomplish specific tasks, such a creating a newsletter or producing a sales presentation, yet
    8·1 answer
  • Why is Abraham called the Father of Believers?
    6·1 answer
  • What is the name used for the camera s view from a single position?
    9·1 answer
  • Which of the following is true of standard error? a. It can take negative values. b. It is an estimate of the standard deviation
    6·1 answer
  • Priscilla is providing the junior analysts in her firm with some real-world illustrations to explain some of the recommendations
    12·1 answer
  • What is the principal goal of data science?<br>​
    5·1 answer
  • The function of anOR gate can best be described as a gate which provides an output of 1 only when
    10·1 answer
  • What are the three general methods for delivering content from a server to a client across a network
    8·1 answer
  • What time is it NOW??
    11·2 answers
  • A(n) ____________________ key is a key that is not reused, but rather is only used once, thus improving security by reducing the
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!