Syntax

import java.*;
import java.io.*;
import java.util.*;

class swap
{
 public static void main(String arg[])
  {
   Scanner sc = new Scanner(System.in);
   System.out.println("Enter First Number : ");
    int n1 = sc.nextInt();
   System.out.println("Enter Second Number : ");
    int n2 = sc.nextInt();
 
 int temp = n1; // n1 = 10 and n2= 20 // temp=10
              n1 = n2; // n1 = 20`
       n2 = temp; // n2 =10
  System.out.println("After Swapping n1 = "+n1+" n2 = "+n2);
  
   }
 }

OUTPUT

Enter First Number :  10
Enter Second Number : 20
After Swapping n1 = 20 n2 = 10

See How to Implement This Program :
please Subscribed this tutorial to : Click here

Leave a Reply

Subscribe to Posts | Subscribe to Comments

All Notes on BCA

All Notes  on BCA
BCA all subjects notes

Total Pageviews

Translate

Powered by Blogger.

Copyright © All Notes on BCA