# Swap two numbers using function

## Problem Statement:-  Program to Swap two numbers using function.

#### Sample Input/Output:-

 Sample Input First:1117 Sample Output First: 1711 Sample Input Second: 3985 Sample Output 8539

#### Data requirement:-

Input Data:- num1, num2

Output Data:-num1, num2

Program in C

Code:

Program in C++

## Here is the source code of the C++ Program to Swap two numbers using function.

Code:

### ``import java.util.Scanner;public class SwapTwoNumbers {    /* This function swap two numbers using third variable */    static void SwapTwoNumberUsingThird(int num1, int num2) {        int temp = num1;        num1 = num2;        num2 = temp;        System.out.println("***After Swapping***");        System.out.println("Number 1:" + num1 + "\nNumber 2:" + num2);    }    public static void main(String[] args) {        Scanner sc = new Scanner(System.in);        /* Get the input of two variables */        System.out.println("Enter the 1st Number:");        int num1 = sc.nextInt();        System.out.println("Enter the 2nd Number:");        int num2 = sc.nextInt();        /* Call Function SwapTwoNumberUsingThird with two Parameters */        SwapTwoNumberUsingThird(num1, num2);        sc.close();    }}``Input/Output:Enter the 1st Number:222Enter the 2nd Number:333***After Swapping***Number 1:333Number 2:222

Program in Python

Code: