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]
3 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]3 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
Will give brainliest
Semmy [17]

Answer:

Computer programmers may advance as project leaders or software developers.

4 0
2 years ago
In what way, if any, are colleges and universities related?
wariber [46]

Answer: c

Explanation:

7 0
3 years ago
Write a program that determines the price of a movie ticket (similar to the one in the chapter). The program asks for the custom
goblinko [34]

Answer:

#include <iostream>

using namespace std;

int main() {

int age,time;

float price;

cout<<"Enter age:";

cin>>age;

cout<<"Enter time(in 24 hour clock for noon 1200):";

cin>>time;

if(age>13){

if(time<1700){

price=5;

}else{

price=8;

}

}else{

if(time<1700){

price=2;

}else{

price=4;

}

}

cout<<"Price: $"<<price<<endl;

}

Explanation:

Okay, here are the steps to be taken in order to be able to Write a program that determines the price of a movie ticket as given in details in the question above. Therefore, checked the steps below;

==> Input the age and the time.

==> If the age is not greater than 13, input the time(that is <1700) and follow it by imputing the price.

And if the age is greater than 13, you will also need to input the price. Just as below;

#include <iostream>

using namespace std;

int main() {

int age,time;

float price;

cout<<"Enter age:";

cin>>age;

cout<<"Enter time(in 24 hour clock for noon 1200):";

cin>>time;

if(age>13){

if(time<1700){

price=5;

}else{

price=8;

}

}else{

if(time<1700){

price=2;

}else{

price=4;

}

}

cout<<"Price: $"<<price<<endl;

}

6 0
3 years ago
Trish has bought a new computer that she plans to start on after a week
7nadin3 [17]
So what is the question my guy?
6 0
3 years ago
You want to connect an external hard drive for backups. Which is the fastest connection used by current external hard drives
Fynjy0 [20]

Answer:

thunderbold proly

Explanation:

5 0
3 years ago
Other questions:
  • Which of the following devices electronically sorts mail by ZIP code? A. Fax modem B. Electronic organizer C. Optical character
    10·1 answer
  • Describe network in terms of the class computer lab
    14·1 answer
  • "______" is a wireless local network that uses high frequency radio signals to transmit an Internet signal from a wireless route
    9·1 answer
  • What would you need to install if you have an app that is incompatible with your current operating system?
    13·1 answer
  • Write a function in the cell below that iterates through the words in file_contents, removes punctuation, and counts the frequen
    6·1 answer
  • Java Eclipse homework. I need help coding this
    6·1 answer
  • Let G = (V, E) be an undirected graph. Design algorithms for the following (in each
    6·1 answer
  • Which XXX and YYY correctly output the smallest values? Vector user Vals contains integers (which may be positive or negative).
    15·1 answer
  • What could be done to make sure that people follow copy right laws?
    13·2 answers
  • David is preparing a report to show the percentage increase in population in the United States in the last five years. Which fea
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!