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
ddd [48]
4 years ago
7

What is the difference between "call by value" and "call by reference"? Explain with example in c language.

Computers and Technology
1 answer:
Serjik [45]4 years ago
7 0

Answer:

<u>Call by reference</u>

In an function if the variables are passed as reference variables this means that the variables are pointing to the original arguments.So the changes made in the function on the reference variables will be reflected back on the original arguments.

For example:-

#include<stdio.h>

void swap(&int f,&int s)

{

   int t=f;

   f=s;

  s =temp;  

}

int main()

{

int n,m;

n=45;

m=85;

swap(n,m);

printf("%d %d",m,n);

return 0;  

}

the values of m and n will get swapped.  

<u> Call by value</u>

In this program the values of m and n will not get swapped because they are passed by value.So duplicate copies of m and n will be created and manipulation will be done on them.

#include<stdio.h>

void swapv(int f,int s)

{

   int t=f;  

   f=s;  

   s=temp;

}

int main()

{  

int n,m;

n=45;

m=85;

swapv(n,m);

printf("%d %d",n,m);

return 0;

}

You might be interested in
How do careers of firefighters and police officer death fire in what ways are they similar​
Reil [10]

Answer:they both save lifes

Explanation:

and mistakes are costly and life risking

4 0
3 years ago
Which of the following configuration files would you document
Nikolay [14]

Answer: B.you have modified a configuration file to mount these new file system automatically

Explanation:

Hope this helped...~DASH

4 0
3 years ago
Which file is usually the first file to be displayed when you navigate to a website?
timurjin [86]

Answer:

3. template.html

Explanation:

5 0
3 years ago
In the early days of photography, cameras were limited to professional photographers because of the knowledge needed to work the
FinnZ [79.3K]
True they had to be developed in a special way in a dark room with several chemicals. 
3 0
4 years ago
Read 2 more answers
Which application software would be most suitable for writing a resume?
Gemiola [76]

Answer:

Either word or I would suggest using google docs and word and compare.

Explanation:

You can set up a resume in word.

7 0
3 years ago
Other questions:
  • Su wants to apply the new font to the other slides of the presentation. She knows she can use the Format Painter tool
    12·1 answer
  • Using a for loop, print the decimal equivalents of ½, 1/3, ¼, … 1/10. Also, using a while loop, print the decimal equivalents of
    6·1 answer
  • What is a System Software ?
    11·2 answers
  • In cell B13, create a formula without a function using absolute references that subtracts the values of cells B5 and
    13·1 answer
  • 9.18 LAB: Exact change - methods Write a program with total change amount as an integer input that outputs the change using the
    11·1 answer
  • 4.2 lesson practice helps plzs
    9·1 answer
  • An array A[0..n - 2] contains `n-1` integers from 1 to `n` in increasing order. (Thus one integer in this range is missing.) Des
    11·1 answer
  • Please help it a timed test
    10·2 answers
  • An intruder with malicious intent breaks into an office and steals a hard drive containing sensitive information about the compa
    12·1 answer
  • How does a file reader know where one line starts and another ends?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!