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
german
4 years ago
13

Write a program in C++ to swap two variables usingfunctions?

Computers and Technology
1 answer:
lilavasa [31]4 years ago
8 0

Answer:

#include <iostream>

using namespace std;

void swap(int& m, int& n)  /* passing by reference so that changes will be made in the original values.*/

{

   int t=m;

   m=n;

   n=t;

}

int main()

{

   int val1,val2;

   cout<<"Enter the values"<<endl;

   cin>>val1>>val2;

   cout<<"Values before swap "<<val1<<" "<<val2<<endl;

   swap(val1,val2); //calling the function swap..

   cout<<"Values after swap "<<val1<<" "<<val2<<endl;

return 0;

}

Explanation:

Created a function swap with 2 arguments m and n passed by reference.

You might be interested in
Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in
Sladkaya [172]

Answer:

The program written in Java is given in the explanation section

Explanation:

public class num9 {

//Defining the method CountCharacters()

   public static int CountCharacters(char userChar, String userString){

       int c = userString.length();

       int count=0;

       for(int i=0; i<c; i++){

           if(userString.charAt(i)==userChar){

               count++;

           }

       }

       return count;

   }

//Main method begins here

   public static void main(String[] args) {

   char n ='n';

   String word = "Monday";

//Calling the method CountCharacters()

       System.out.println(CountCharacters(n,word));

   }

}

4 0
3 years ago
The term used for doing business online is referred to as ___.
liubo4ka [24]
The process for doing business online is referred to as e-commerce.
6 0
3 years ago
How does an Ac Machine work
Pani-rosa [81]

Answer:

In a split system, the compressor condenses and circulates the refrigerant through the outdoor unit, changing it from a gas to a liquid. The liquid is then forced through the indoor evaporator coil or cooling compartment. The indoor unit's fan circulates the inside air to pass across the evaporator fins.

Explanation:

(hope this helps)

6 0
3 years ago
Please help me please i’ll give brainli
DaniilM [7]
Answer: a digital bulletin board
4 0
3 years ago
What are examples of real-time applications
Savatey [412]

Typical examples of real-time systems include Air Traffic Control Systems, Networked Multimedia Systems, Command Control Systems etc.

3 0
4 years ago
Other questions:
  • Which is a network of devices built around a person, typically within 10 meters of range?
    5·1 answer
  • What is telepresence
    8·1 answer
  • What does it mean for a school to be “accredited”?
    5·1 answer
  • Consider the following relational schema, where the primary keys are Bold,
    7·1 answer
  • Where are the Add Level and Delete Level buttons located? Filter options list Sort &amp; Filter group Sort dialog box Custom fil
    11·1 answer
  • Grading on the curve is a method of grading that is based on the belief that letter grades for any given class should be distrib
    8·1 answer
  • CHEMISTRY. metal+water》base+...............​
    12·1 answer
  • Alright, so I have a wireless mouse that uses a dongle (it's not Bluetooth nor wired). But recently I realized that none of the
    12·1 answer
  • I love this an this a a good app ❤️❤️❤️​
    5·2 answers
  • 2.3 Code Practice: Question 1
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!