Array-promo

Question

Program to swap two numbers.

Share code with your friends

Share on whatsapp
Share on facebook
Share on twitter
Share on telegram

Code

import java.util.Scanner;
public class Swap_With
{
    public static void main(String[] args)
    {
       int a, b, temp;// a and b are to swap
       Scanner sc = new Scanner(System.in);
       System.out.println("Enter the value of a and b");
       a = sc.nextInt();
       b = sc.nextInt();
       System.out.println("before swapping numbers: Value of a: "+a +" Value of b:  "+ b);
       /*swapping */
       temp = a;
       a = b;
       b = temp;
       System.out.println("After swapping: Value of a: "+a +" Value of b:  "+ b);
       System.out.println( );
    }
}

Coding Store

Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹250.Current price is: ₹150.
Sale

Original price was: ₹350.Current price is: ₹200.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale
Mastering Array

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.

Leave a Reply

Your email address will not be published. Required fields are marked *