Skip to content

Commit

Permalink
addition,expression,subtraction in java
Browse files Browse the repository at this point in the history
  • Loading branch information
suhanigupta23 authored Dec 25, 2023
1 parent 71344ef commit 4a1b4c9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions addprdexp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
public class Program
{
public static void main(String[] args)
{
//divsion,addition,modulus,multiplication.
int x=10;
int y=15;
int sum=x+y;
int prd=x*y;
int div1=x/y;
int div2=y/x;
int mod=y%x;
System.out.println("Sum of "+x+" and "+y+" is "+sum);
System.out.println("Product of "+x+" and "+y+" is "+prd);
System.out.println("Division of "+x+" and "+y+" is "+div1);
System.out.println("Division of "+y+" and "+x+" is "+div2);
System.out.println("Modulus of "+y+" and "+x+" is "+mod);
//expression
int exp=x*y/x+y;
//BODMAS applied system reads it as
// exp=( x*(y/x) ) + y
System.out.println("Expression value is " +exp);
int exp1= (x*y)/(x+y);
System.out.print("Expression2 value is " +exp1);

}
}

0 comments on commit 4a1b4c9

Please sign in to comment.