filmov
tv
#9 Arithmetic Operators in Java
Показать описание
Check out our courses:
Coupon: TELUSKO10 (10% Discount)
Udemy Courses:
For More Queries WhatsApp or Call on : +919008963671
In this lecture we are discussing:
1)Assignment operator
a) = is used to assign a value to a variable
b) += is used to assign a value to a variable by adding it to the existing value
c) -= is used to assign a value to a variable by subtracting it from the existing value
-- there are many but in this lecture we discussing only some
e.g of =
int num1=11;
int num2=12;
int result = num1 + num2;
int result1=num1-num2;
int result2=num1*num2;
int result3=num1/num2;
e.g of +=
int num=1;
num +=1; = num = num+1;
num +=5; = num = num+5;
e.g of -=
int num2=2;
num -=1; num =num-1;
num -=5; num =num-5;
2)increment and decrement operator
-- there are two type of increment and decrement operator
a) pre
b) post
-- post increment and decrement operator
int num=1;
num++;
-- this operator is known as post increment operator
num--;
-- this operator is know as post decrement operator
-- pre increment and decrement operator
int num=2;
++num;
--num;
Difference between pre and post operator
e.g for that we take one example
int num=5;
int num1=5;
in post
first assignment and then increment
e.g int num=5; int copy;
copy=num++; in this case first num=5 assign to copy then increment the num
copy value is 5;
in pre
first increment then assignment
e.g int num=5;
int copy;
copy = ++num;
in this case first increment num value from 5 to 6 then assign to copy.
copy value is 6;
More Learning :
Donation:
PayPal Id : navinreddy20
Coupon: TELUSKO10 (10% Discount)
Udemy Courses:
For More Queries WhatsApp or Call on : +919008963671
In this lecture we are discussing:
1)Assignment operator
a) = is used to assign a value to a variable
b) += is used to assign a value to a variable by adding it to the existing value
c) -= is used to assign a value to a variable by subtracting it from the existing value
-- there are many but in this lecture we discussing only some
e.g of =
int num1=11;
int num2=12;
int result = num1 + num2;
int result1=num1-num2;
int result2=num1*num2;
int result3=num1/num2;
e.g of +=
int num=1;
num +=1; = num = num+1;
num +=5; = num = num+5;
e.g of -=
int num2=2;
num -=1; num =num-1;
num -=5; num =num-5;
2)increment and decrement operator
-- there are two type of increment and decrement operator
a) pre
b) post
-- post increment and decrement operator
int num=1;
num++;
-- this operator is known as post increment operator
num--;
-- this operator is know as post decrement operator
-- pre increment and decrement operator
int num=2;
++num;
--num;
Difference between pre and post operator
e.g for that we take one example
int num=5;
int num1=5;
in post
first assignment and then increment
e.g int num=5; int copy;
copy=num++; in this case first num=5 assign to copy then increment the num
copy value is 5;
in pre
first increment then assignment
e.g int num=5;
int copy;
copy = ++num;
in this case first increment num value from 5 to 6 then assign to copy.
copy value is 6;
More Learning :
Donation:
PayPal Id : navinreddy20
Комментарии