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
Romashka-Z-Leto [24]
3 years ago
8

Write a C++ program to exchange values of two variables using function exchange().

Computers and Technology
1 answer:
Shkiper50 [21]3 years ago
6 0

Answer:

#include<iostream>

using namespace std;

//create the exchange function

void exchange(int a, int b){

   int temp;  //initialize temporary

   //swap the variables value

   temp=a;

   a=b;

   b=temp;

   //print the output after exchange

   cout<<"a is: "<<a<<endl;

   cout<<"b is: "<<b<<endl;

}

//main function program start from here

int main(){

  //initialization

  int a=3, b=6;

  exchange(a,b);  //calling the function

  return 0;

}

Explanation:

Create the function exchange with two integer parameter which takes the value from the calling function.

and then declare the third variable temp with is used for swapping the value between two variables.

first store the value of 'a' in the temp and then assign the 'b' value to 'a' and then, assign the temp value to b.

for example;

a=2, b=9

temp=2;

a=9;

b=2;

So, the values are swap.  

and then print the swap values.

Create the main function and define the input a and b with values.

Then, calling the exchange function with two arguments.

You might be interested in
Does any body know the name of this sensor? ​
kipiarov [429]

Answer:

ummm it looks like a fingerprint sensor

Explanation:

here a similar pic to it .i hope this helps :)

5 0
3 years ago
One part of a development team has completed an algorithm. Why is it important to share it with others on the team? Choose all t
Nadusha1986 [10]

Answer: B,C,D

Explanation:

5 0
3 years ago
In this for loop, identify the loop control variable, the initialization statement, loop condition, the update statement, and th
KATRIN_1 [288]

Answer:

Follows are the solution to these question:

Explanation:

Please find the complete question in the attached file.

For point a:

The "j" is the loop control variable that controls this loop  

For point b:

The initialized statement for the given loop is "j = 1"

For point c:

The loop condition for the given loop is "j<=10" which indicates that the value of j is less than equal to 10.

For point d:

The loop given statement that updates the value of the s is "s = s+j*(j-1)".

8 0
3 years ago
&gt;&gt;&gt; import math &gt;&gt;&gt; print(math.Pi) 3.141592653589793 &gt;&gt;&gt; def print_volume(): print ("What is the radi
kvasek [131]
I have no clue what this is asking...
8 0
3 years ago
Anna is making a presentation on the solar system. She wants to emphasize the planet names as they appear one by one on the pres
Svetach [21]

slide transition effect.

5 0
3 years ago
Other questions:
  • What is the difference between First Person Shooters and Construction Simulations?
    12·2 answers
  • Why is it important to back up data on a computer before you burn-in test the cpu?
    9·1 answer
  • Build a state diagram for the “book” based upon the following information of the library.
    6·1 answer
  • When an application contains an array and you want to use every element of the array in some task, it is common to perform loops
    14·1 answer
  • Create a simple self-checkout system. Prompt for the prices and quantities of three items. Calculate the subtotal of the items.
    15·1 answer
  • If a computer truncatesall numbers to two decimal places, compute the error forthe following: 23.345+222.34911)0.12)0.01413)0.14
    15·1 answer
  • The "great big secret" Ohanian talks about is the idea that:
    15·1 answer
  • What are interpersonal skills for non-technical user
    14·1 answer
  • 2. Cryptography relies on open standards - a protocol or standard that is publicly available. Why are open standards necessary
    5·1 answer
  • Write a function called printRange() that accepts two integers as arguments and prints the sequence of numbers between the two a
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!