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]
4 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]4 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
On tool hackers use to get sensitive information from victims is/are:
Feliz [49]
Pretty sure it’s keyloggers because it’s the only one that makes sense to me but I’m not 100% sure on that one
5 0
3 years ago
Read 2 more answers
What are the advantages of renting a home over buying a home? What are some disadvantages?
weqwewe [10]
An advantage of renting a home is that you don't have to fix any appliances or structures of the home your landlord does that for you. disadvantages are you have to follow their rules, you can't change anything on the inside like the paint or add a room to the home. in the state of Washington and landlord can evict you with only 20 days notice if they want to permanently sell the property. that's called a no-fault eviction. that's all I can think of hope that helps
7 0
3 years ago
A(n) Answer display color uses the least electricity when compared to any other color.
Elan Coil [88]

Is there answer choices because I’m not understanding what you want me to answer

3 0
3 years ago
The space that helps you organize your PowerPoint or Web Page is called ______.
sergeinik [125]

Answer:

the internet

Explanation:

cause I said

8 0
3 years ago
Which word is most appropriate to describe a laptop?
Thepotemich [5.8K]
The best word to describe a laptop would be Portable
8 0
3 years ago
Other questions:
  • "which part of an information system consists of the rules or guidelines for people to follow?"
    9·1 answer
  • Write a program for Horizon Phones, a provider of cellular phone service. Prompt a user for maximum monthly values for talk minu
    6·1 answer
  • Which term means a device that converts one voltage to another?
    13·1 answer
  • Match the keyboard shortcuts to the function they perform
    10·1 answer
  • Which famous individuals was born on october 31st?
    7·1 answer
  • 7.
    15·1 answer
  • When engineers consider _____, they propose giving up a benefit of one proposed design in order to obtain a benefit of a differe
    14·1 answer
  • Tell me the most scariest website you know and i'll give you brainlest
    5·1 answer
  • Describe your ideas for a keyboarding game that would help someone improve their skills.
    6·1 answer
  • which endpoint application runs on an endpoint device that only detects an attack in an endpoint device? chqgg
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!