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
swat32
3 years ago
11

Write a program whose input is two integers and whose output is the two integers swapped.

Computers and Technology
1 answer:
Tpy6a [65]3 years ago
5 0

Answer:

The program to this question can be given as:

Program:

#include <iostream>  //header file

using namespace std;   //using namespace.

void SwapValues(int* userVal1, int* userVal2); //function declaration.

void SwapValues(int* userVal1, int* userVal2) //function definition.

{ //function body.

//perform swapping

   int t = *userVal1;  

   *userVal1 = *userVal2;

   *userVal2 = t;

}

int main() //main method  

{

int n1, n2; //define variable

cout<<"Enter first number :"; //message

cin>>n1; //input by user.

cout<<"Enter second number :"; //message  

cin>>n2; //input by user.

SwapValues(&n1,&n2); //calling function.

cout<<"Swapped values"<<endl;

cout<<"first number is :"<<n1<<endl; //print value

cout<<"second number is:"<<n2<<endl; //print value

return 0;

}

Output:

Enter first number :3

Enter second number :8

Swapped values

first number is :8

second number is :3

Explanation:

The description of the above C++ language program can be given as:

  • In the program, firstly we include the header file. Then we declare and define a function that is "SwapValues()" function in the function we pass two integer variable that is "userVal1 and userVal2" inside a function, we define an integer variable that is "t" and perform swapping.  
  • Then we define the main function in the main function we define two variables that is "n1 and n2" this variable is used to take value-form user. then we pass this value to function and print the function values.

You might be interested in
What are some of the challenges that could arise from setting up a file management system on a computer
Katarina [22]
<span>You could download some software that could mess up your whole computer.</span>
3 0
3 years ago
how write a program to prompt the user for hours and rate per hour using input to computer gross pay Use 35 hours and rate2.75 p
Juli2301 [7.4K]

Answer:

Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Use 35 hours and a rate of 2.75 per hour to test the program (the pay should be 96.25). You should use input to read a string and float() to convert the string to a number. ... #compute gross pay bye hours and rate per hour.

Explanation:

3 0
4 years ago
When you record a macro, all of the actions are converted by the program to code
Yuri [45]

Yes you are creating a list of actions based off the previous

5 0
3 years ago
Read 2 more answers
Apple's macos and microsoft windows are examples of ________ software. select one:
Soloha48 [4]
D.operating system
mac is an unix based os
3 0
3 years ago
Which of the following which of the following is an advantage of using functions ​
Paha777 [63]

Answer:

kkbvvvvvvvvvvvvvvvvv'vvvkk

4 0
3 years ago
Other questions:
  • IF YOU GET THIS RIGHT U GET BRAINLIEST
    14·2 answers
  • g What field in the IPv4 datagram header can be used to ensure that a packet is forwarded through no more than N routers? When a
    10·1 answer
  • With iteration-control systems, each team member ________. is given an account with a set of permissions is given their own priv
    6·1 answer
  • The use of electronic media, information, and communication technologies to deliver instruction where students are not required
    8·1 answer
  • Liam is a hacker who tries to access Wi-Fi signals while driving his car. What type of wireless network attack is this?
    9·1 answer
  • Server 2016 is compatible for Powershell 5.0 State True or False.
    7·1 answer
  • Write a program that prompt the user to enter the coordinate of two points (x1, y1) and (x2,y2), and displays the slope of the l
    10·1 answer
  • How does violating the SOLID principles make code hard to test?
    5·1 answer
  • Which structure does a web page normally use to define an area of focus <br>​
    9·1 answer
  • HTML, the markup language of the web, specifies colors using the RGB model. It uses a two-digit hexadecimal (that is, base 16) r
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!