Java Program Using All Arithmetic Operators
Java Program Using All Arithmetic and Assignment Operators |
class Arithmetic
{
public static void main(String s[])
{
int a=23, b=18, c;
c=a+b;
System.out.println("addition of two number is"+ c);
int p=23, q=18, r;
r=p*q;
System.out.println("multiply of two number is"+ r);
int w=23, e=18, x;
x=w/e;
System.out.println("division of two number is"+ x);
int m=23, n=18, o;
o=m-n;
System.out.println("substracti on of two number is"+ o);
}
}
{
public static void main(String s[])
{
int a=23, b=18, c;
c=a+b;
System.out.println("addition of two number is"+ c);
int p=23, q=18, r;
r=p*q;
System.out.println("multiply of two number is"+ r);
int w=23, e=18, x;
x=w/e;
System.out.println("division of two number is"+ x);
int m=23, n=18, o;
o=m-n;
System.out.println("substracti
}
}
Arithmetic Operators
Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication etc.
Operator | Meaning |
---|---|
+ | Addition (also used for string concatenation) |
- | Subtraction Operator |
* | Multiplication Operator |
/ | Division Operator |
% | Remainder Operator |
Assignment Operator
Assignment operators are used in Java to assign values to variables. For example,
int tech;
tech = 5;
Example 1: Assignment Operator
class AssignmentOperator {
public static void main(String[] args) {
int value1, value2;
// Assigning 5 to value1 value1 = 5; System.out.println(value1);
// Assigning value of variable value2 to value1 value2 = value1; System.out.println(value2); }
}
When you run the program, the output will be:
5
5
You made such an interesting piece to read, giving every subject enlightenment for us to gain knowledge. Thanks for sharing the such information with us to read this... aktieanalys
ReplyDeleteYou made such an interesting piece to read, giving every subject enlightenment for us to gain knowledge. Thanks for sharing the such information with us to read this... aktieanalys
ReplyDelete