Array-promo

Question

Write a program to Subtract two numbers.

				
					Enter the value of 1st number
10
Enter the value of 2nd number
20
10-20=-10
				
			

Share code with your friends

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

Code

				
					import java.util.Scanner;
 public class  SubtractTwoNumbers
{
  public static void main()
  {
    Scanner sc=new Scanner(System.in);
    int a =0,b=0;
    System.out.println("Enter the value of 1st number");
    a=sc.nextInt();
    System.out.println("Enter the value of 2nd number");
    b=sc.nextInt();
    // subtracting A and B
    int sub = a-b;   
    // Print the subtract of a and b
    System.out.println(a+"-"+b+"="+sub);
  }
}

				
			

Coding Store

Leave a Reply

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