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
A computer can manipulate symbols as if it understands the symbols and is reasoning with them, but in fact it is just following
Law Incorporation [45]

Answer:

The symbols may or may not have meaning, but the machine does not need to know how the symbols are interpreted in order to manipulate the symbols in the right way.

Explanation:

The computer can change the symbols in the case when the computer understand but in actual following the cut-paste rules without having any understanding this is because the symbols might be have meaning or not but if we talk about the machine so actually they dont know how the symbols are interpreted and how it can be used so that it can be change in the accurate way

5 0
2 years ago
Before guis became popular, the _______________ interface was the most commonly used.
sineoko [7]
<span>Before GUIs became popular, the command line interface (CLI) was the most commonly used.
</span>GUI stands for Graphical User Interface . Like its name says it is a graphical interface <span>that allows interaction with users through graphical icons and visual indicators , rather than through text-based interface.</span><span>
Command line interace (CLI) is text-based interface in which </span>the user <span>issues commands to the program in the form of successive lines of text.</span>
6 0
3 years ago
What pointer appears when pointing to a hyperlink
Leokris [45]
Your answer would be: a hand pointer.
6 0
3 years ago
Read 2 more answers
When using the Common Internet File System (CIFS), which security model will require network users to have a user name and passw
hjlf

Answer:

User-level Security

Explanation:

User-level security allows the user to access resources on a network using a username and password. User-level security offers higher and greater security than share-level security, which does not require a password to access files.

User-level security allows the database user access and permission to resources.

4 0
3 years ago
Hlo friends what is full form of RAM and ROM ​
Usimov [2.4K]

Answer:

Hello.

Explanation:

The full form of

RAM=Random Acess Memory.

ROM=Read Only Memory.

6 0
2 years ago
Read 2 more answers
Other questions:
  • Ron wants to install an energy efficient and long lasting device for lighting in his new home. Which device should he use?
    11·2 answers
  • Determine whether or not the following pairs of predicates are unifiable. If they are, give the most-general unifier and show th
    13·1 answer
  • There are parallels between the trust models in Kerberos and Public Key Infrastructure (PKI). When we compare them side by side,
    15·1 answer
  • Explain the bad effect and good effect of mobile phone and internet.<br>​
    15·2 answers
  • Two forms of compression are lossy and lossless. State giving reasons which
    8·1 answer
  • Which tool allows users to share code and also serves as a social networking
    10·1 answer
  • What statement best describes entrepreneurship?
    7·2 answers
  • 2. Give technical terms for
    13·1 answer
  • You text file begins with the following rows. The pattern is a description of the item to be repaired, its color, and the issue.
    14·1 answer
  • To stored three characters a computer occupies. Bytes memory space
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!