Write a program to find z = (a+b) –(a-b).in java
Answers
Answered by
1
Answer:
import java.io.*;
class number
{
public static void main(String arg[])throws Exception
{
int a,b,z;
DataInputStream in=new DataInputStream(System.in);
System.out.print("enter the value of a and b respectively");
a=Integer.parseInt(in.readLine());
b=Integer.parseInt(in.readLine());
z=(a+b)-(a-b);
System.out.println(z+"is the output");
}
}
Answered by
2
Answer:
//Program to print (a+b)-(a-b)
import java.util.*;
class abc{
public static void main (String ar []){
Scanner sc=new Scanner(System.in);
System.out.println("Value of a and b?");
int a=sc.nextInt();
int b=sc.nextInt();
int z=(a+b)-(a-b);
System.out.println("Results:"+z);
}
}
Required Output Attached.
Attachments:
Similar questions