+ 3
How does incremental and decremental operators works ..!!
For example if a = 0 and b = 1 then what's the answer for ++a && b--
5 Answers
+ 10
From what I know , they both give the same answer.
+ 9
Example:
a=1
a++ is the same as a=a+1
b=1
b-- is the same as b=b-1
I hope this helps.đ
+ 2
// post and pre increment is not same
// java
public class Program {
public static void main(String[] args) {
int a = 0;
System.out.println( a++ + a ); //output 1
a = 0;
System.out.println( ++a + a ); //output 2
}
}
// because
// (a++ + a) do (p1+p2) where (p1=0; a=a+1; p2=a) so (0+1) =1
// (++a + a) do (p1+p2) where (a=a+1; p1=a; p2=a) so (1+1) =2
+ 1
What's the difference between post and pre increment or decrement....does both gives the same answer?? đ§Alex Tusineanđ„
what is the output of the following code?
int a = 8 , b = 9;
if((++a>8) && (--b>=9))
print("b");
else
print("a");
+ 1
Post increment ( a++): assigns the value and increments
For eg: y=a++; means
y=a; and then
a=a+1;
Similarly pre increment means it increases and assigns the value