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
Consider the key success factors of B2C. Is it only IT? What is most important?​
Ad libitum [116K]

Jsjfu zzer jsusuc888 kksss

6 0
3 years ago
How do you flatten a 2D array to become a 1D array in Java?
Leni [432]

Answer:

With Guava, you can use either

int[] all = Ints.concat(originalArray);

or

int[] all = Ints.concat(a, b, c);

Explanation:

Use GUAVA

4 0
2 years ago
The rules of a programming language constitute its__________________
kogti [31]
The rules of a programming language constitute its syntax.
7 0
2 years ago
Which of the following is not a common network architecture type?
solong [7]

Answer:

c

Explanation:

i guess bcs i didnt learn this actually

3 0
3 years ago
3.2.3 What major al able to do? 3.2.4 What major advantage would Printer X have for Tembi who want documents printed? 3.3 If Tem
zzz [600]

Answer:

she or he will use handouts

6 0
2 years ago
Other questions:
  • Import java.util.scanner; public class sumofmax { public double findmax(double num1, double num2) { double maxval; // note: if-e
    10·1 answer
  • What is the maximum number of columns in a spreadsheet that you can sort in one instance in software like OpenOffice Calc?
    7·2 answers
  • Which step needs to be done before changing the font type, size, and color of a particular set of text
    7·1 answer
  • Reversing the elements of an array involves swapping the corresponding elements of the array: the first with the last, the secon
    11·1 answer
  • In 1988, Robert Morris, Jr. launched a program called the _________ that used weaknesses in e-mail programs and operating system
    5·1 answer
  • The special operator used to check for similar character strings is ____.
    13·1 answer
  • Accessing disk is much slower than accessing memory. As a result, many file systems have been designed with various optimization
    7·1 answer
  • Why do you think it is important to know typography and color when designing web sites?
    15·2 answers
  • PLEASE HELP ASAP what is the main purpose of electronic speed controller ESC
    9·2 answers
  • Scott sends his backups to a company that keeps them in a secure vault. What type of backup solution has he implemented?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!