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
Assume that the demand curve for DVD players shifts to the left and the supply curve for DVD players shifts to the right, but th
kari74 [83]

Answer:

a.both the equilibrium price and quantity of DVD players will decrease

Explanation:

When the amount required or given varies, even if the price stays the same, a move in the demand or supply curve occurs. Changes in the curve of demand mean that the initial relationship of production has shifted so that demand of quantity has a factor apart from cost influenced

A right shift change of the supply curve shows an increase in supply and, on equal footing, the equilibrium price decreases.

Once the demand curve shifts to the left, the demand decreases.

7 0
3 years ago
Why don't we get together to watch the Academy Awards?
Step2247 [10]

Answer:

idk I'm not sure cause yeah

5 0
3 years ago
Read 2 more answers
Write a program that uses two input statements to get two words as input. Then, print the words on one line separated by a space
Shkiper50 [21]

word1 = input("Enter a word: ")

word2 = input("Enter a word: ")

print(word1 + " " + word2)

I hope this helps!

6 0
3 years ago
Under what driving conditions will 2019 Nissan LEAF’s available Rear Cross Traffic Alert (RCTA) warn the driver if a vehicle is
Dmitriy789 [7]

Answer:

When the driver is <em>reversing the car</em>

Explanation:

The Rear Cross Traffic Alert (RCTA) is Nissan's <em>risk  of collision detector</em> that warns drivers if one or more cars are approaching the rear of your car when backing up from a parking space.  

Sensors around the back of the vehicle identify vehicles drawing nearer from the either way. A notice tone and glimmering light will appear and  alert the driver to stop.  

5 0
3 years ago
Who Find the exact web server that hosted the website by looking in a huge database of internet addresses
son4ous [18]

Answer:

The Internet service provider (ISP)

Explanation:

The internet service provider provides individuals and other companies access to the internet and other web services. The internet service provider looks through a huge database of internet addresses to find the exact web server that a website is hosted on when a query is sent.

4 0
3 years ago
Other questions:
  • The purpose of the ________ element is used to configure the main content of a web page document.
    5·1 answer
  • Can I recover my data from HDD if I just started formatting but did not finish it? (I ceased it!)
    7·1 answer
  • Open a command prompt on pc-a and pc-b and type ipconfig /all. what are the ethernet adapter physical addresses?
    7·1 answer
  • What are the keys in all rows that sit between the touch keys
    11·1 answer
  • Ted is looking for a reliable source for his paper. Which of the following sites would be considered reliable?
    5·1 answer
  • In powerpoint a point is _____ of an inch in height.
    6·1 answer
  • Cuál ha sido el papel de las tecnologías de la información y los medios de comunicación en el fenómeno de la globalización​
    10·1 answer
  • Scrie un program care citind varstele a 2 copii afiseaza care dintre ei este cel mai mare si cu cat. Exemplu: Pentru varstele 5
    9·1 answer
  • Poob bn vbyfcfgxfc jghjg jhgh
    12·1 answer
  • How do I fix when it hits the second session it skips scanf..
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!