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
Agata [3.3K]
3 years ago
15

8.8 Lab: Swapping variables Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the

input is 3 8, then the output is 8 3 Your program must define and call a function. SwapValues returns the two values in swapped order. void SwapValues(int& userVal1, int& userVal2) zybooks c++ g
Computers and Technology
1 answer:
Scilla [17]3 years ago
4 0

Answer:

Following are the program in c++ language

#include<iostream> // header file

using namespace std; // using namespace

void swapvalues(int&  userVal1, int& userVal2);// fucnction declaration

int main() // main method

{

   int x,y; // variable declaration

   cout<<"Enter the two value before swapping:\n";

   cin>>x>>y; // read the two input

  cout<<"before swapping:";

  cout<<x<<y; // display the value before swapping

   swapvalues(x, y);

   cout << "\nAfter swapping:";

   cout<<x<<y; // display the value after swapping

   return 0;

}

void swapvalues(int&  userVal1, int& userVal2) // function definition

{

   int t; // variable declaration

   t = userVal1; // assign the value userval1 to variable t

   userVal1 = userVal2; // assign the value userval2 to userval1

   userVal2 = t; // assign the value of variable t to userval2

}

Output:

Enter the two value before swapping:

3

8

before swapping:3 8

After swapping   :8 3

Explanation:

Following are the description of the program

  • Declared a variable "x" and "y" of type "int".
  • Read a input by user in x and y .
  • Display the values of variable x and y before the swapping.
  • Call the function  swapvalues() by passing the value of x and y.
  • After calling the console moved In the definition of swapvalues() Function where it interchanged the value of variable userVal1 and userVal2 by using third variable "t".
  • After interchanged the console moved to the main function and finally display the value of variable "x" and "y' after the swapping.

You might be interested in
Draw a flowchart that ask the user to enter number: if the number is less than then 10 number it is doubled if the number is mor
solong [7]

Answer:

please find the attachment of the flowchart.

Explanation:

In this question, a start block is used to start the program, in the parallelogram box we input the value from the user end and in the diamond box, we check the input is not equal to 0. In the next diamond box, it checks the given input value and print value, and at the last, we stop the code.

Please find the program and its output in the attached file.

8 0
3 years ago
This is tech question related to mobile and PC.
love history [14]

I am guessing the bluetooth process is same as usb proccess. So when i transfered a video via usb and took out the usb (for apple phone), there <u>was</u> a file but when i clicked it it said that the phone isn't plugged in

4 0
3 years ago
When you open as many links as you want, and still stay in the same browser window instead of cluttering your screen with multip
emmainna [20.7K]

Answer:

a. Tabbed browsing

Explanation:

Tabbed browsing is a feature in the browser that helps in operating several tabs at the same time. It helps in browsing different links without opening different browsers. Multiple pages can be opened and surfed at the same time in one window. Any link can be opened in a different or new tab by clicking right on the link. After this, 'open link in new tab' is to be selected and the link gets opened respectively.

3 0
3 years ago
How many yards must you run to complete a 100 meter dash?
ddd [48]
103 yards in a 100 meter dash
<span />
4 0
3 years ago
Read 2 more answers
Kelly completes a bachelor's degree in animation from a top school in New York. She would now like to look for a job that will p
nikdorinn [45]
I believe she would have a best chance in a media production house, animation is a form of media and would be best put to use there.
8 0
3 years ago
Read 2 more answers
Other questions:
  • What process combines data from a list with the content of a document to provide personalized documents?
    10·1 answer
  • Data means a group of numbers. <br> a. True<br> b. False
    7·1 answer
  • Hackers often argue that hacking is for the good of all people because it points out flaws in computer systems. do you agree wit
    6·1 answer
  • Hey!! Can u help me please!!​
    12·2 answers
  • And tags are examples of stand - alone tags.
    15·1 answer
  • Which benefit does the cloud provide to star-up companies without access to large funding?
    11·1 answer
  • Question 7<br> What is the description of The Ribbon?
    14·1 answer
  • Whats th diffence between a fwireless speaker and a wird speakr
    12·1 answer
  • Language is PYTHON
    6·1 answer
  • The storage capacity of Go ogle drive can be increased from ____________.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!