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
Who wants to join my go.ogle classroom?
Ostrovityanka [42]

Answer:

sure

Explanation:

8 0
3 years ago
Read 2 more answers
This morning when Paul turned on his computer at work, it would not boot. Instead, Paul reported that he heard a loud clicking n
IRISSAK [1]

Answer:

The problem with Paul's computer is that the magnetic hard drive failed.

Explanation:

A magnetic hard drive or hard disk is a non-volatile storage device, which is used to store different information on a computer.

The magnetic disk is made up of numerous magnetic plates, these plates are divided into sectors and tracks. A spindle is present in the middle to rotate the combined plates or the whole unit.

When there is a clicking noise coming from the magnetic disk, it could mean that one of the plates is damaged or if the power to the computer is inconsistent. This can greatly affect the performance of your computer.

3 0
4 years ago
Kurt is editing a table in his powerpoint that displays accounting formulas and when to use them. he wants to remove the table s
Olenka [21]
The feature that Kurt should use is the split feature. 
7 0
3 years ago
What is the main function of an operating system​
alina1380 [7]

Here are the main functions of an operating system:

1) Manage the resources of the device

The operating system controls how much of each resource is distributed, and it controls things like the processing unit and memory.

2) Establish a interface for the user of the device

The operating system must classify what the classes of the script/code have to do and what they implement.

3) Service application software

The operating system must service each application that is downloaded onto the device. It must balance it's use of storage between apps.

4 0
3 years ago
Graphic designers sometimes must adjust the spacing between letters so that the result looks right to them. This is called
joja [24]
<span>B. optical spacing. Because they want to look right to them and only issue is their eyes, so answer is B.</span>
3 0
4 years ago
Other questions:
  • Ordering a mocha latte and paying for it from the starbucks smartphone app is using what type of internet commerce? (1 point) c2
    7·1 answer
  • Describe the difference between public and private IPv4 addresses. If a network is using private IP addresses, how can the compu
    13·1 answer
  • The labor market shows the:
    11·1 answer
  • When you type into a basic search engine like Google, Bing, or Yahoo!, the sites that appear at the top or on the side of the re
    7·1 answer
  • Which of the following is a reason that a drug may not receive FDA approval?
    15·1 answer
  • Ian recently earned his security certification and has been offered a promotion to a position that requires him to analyze and d
    6·1 answer
  • Your program should first save 10 random numbers from 1-100 to an array called aray
    12·1 answer
  • Question 1. (50 points) 1.Write a program that computes information related to a sequence of entries regarding age of customers.
    6·1 answer
  • 10. Why antivirus is needed to be installed in computer system?
    8·1 answer
  • The term for an operator that may not evaluate one of its subexpressions is
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!