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
Maurinko [17]
3 years ago
7

Taking a suitable example in c language explain the of call by value and call by reference concepts.

Computers and Technology
1 answer:
Degger [83]3 years ago
8 0

Answer: The difference between call by value and call by reference is that in call by value the actual parameters are passed into the function as arguments whereas in call by reference the address of the variables are sent as parameters.

Explanation:

Some examples are:

call by value

#include <stdio.h>  

void swap(int, int);

int main()

{  int a = 10, b= 20;

 swap(a, b);

 printf("a: %d, b: %d\n", a, b);

}  

void swap(int c, int d)

{

 int t;

 t = c; c = d; d = t;

}  

OUTPUT

a: 10, b: 20

The value of a and b remain unchanged as the values are local

//call by reference

#include <stdio.h>

 void swap(int*, int*);

 int main()

{

 int a = 10, b = 20;

 swap(&a, &b);   //passing the address

 printf("a: %d, b: %d\n", a, b);

}

void swap(int *c, int *d)

{

 int t;

 t = *c; *c = *d; *d = t;

}

OUTPUT

a: 20, b: 10

due to dereferencing by the pointer the value  can be changed which is call by reference

You might be interested in
bro i got banned for posting an amazing bulk pic, but this dude literally posted an inappropriate, dafuq is wrong with this bann
Ludmilka [50]

Answer:

okkk

Explanation:

5 0
3 years ago
Read 2 more answers
Why computer known as tool of information​
S_A_V [24]

Answer:

because it has the ability to capture the whole information you need or downloaded

8 0
2 years ago
What is one benefit of using electronic sticky notes ?
balu736 [363]
They can be used to just copy/paste e-mailed information without writing down on a paper and losing valuable time. This is one example.
4 0
3 years ago
Read 2 more answers
You need to prevent the use of tftp through your firewall. which port would you block?
xz_007 [3.2K]
Hello <span>Huber5598 </span>


Question: <span>You need to prevent the use of tftp through your firewall. which port would you block?
</span><span>
Answer: You should block UDP port 69 to block TFTP


I Hope This Helps You :-)
-Chris</span>
4 0
3 years ago
How does the purchase of office equipment on account affect the accounting equation?
Nina [5.8K]
A. Assets increase, and liabilities decrease.
6 0
3 years ago
Read 2 more answers
Other questions:
  • My computer keeps shutting down I've tried to completely wipe the memory but it didn't work do you have any ideas how to fix it
    7·1 answer
  • Fix the 2 error codes.
    14·1 answer
  • Emma has decided that she needs to assess the risk and return of buying an extended warranty for her new laptop for school
    15·1 answer
  • Write a program that responds to a positive integer passed on the command line with the number of bits needed to express that nu
    10·1 answer
  • To what would you compare the transport layer?
    14·1 answer
  • What two pieces of information would you need in order to measure the masses of stars in an eclipsing binary system?
    9·1 answer
  • HELP PLEASE!!! I do online school, someone is in another state wanting to help me. No not do my work for me but view what I view
    6·1 answer
  • How is the bootstrap program started?
    6·2 answers
  • CAN SOMEONE PLEASE DO THESE FOR ME I WILL GIVE BRAINLIESR AND 20 POINTS PLEASE ITS ONLY 5 QUESTIONS PLEASEEEE
    12·1 answer
  • Which tool uses images and other visual elements to provide artistic
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!