different output c and java programwhat is the output of this c and java in same code/programs...and why,output is different.?
// c program
printf("%d %d",++i,i++ );
p s v m(String arg)
println(++i +""+ i++);
in Java - the value of i will be incremented by ++i as it is an pre-increment statement and value of i will become 3 then for post increment statement the value of i will be changed in the memory but it will use the same value as 3 so the output will be 3 3 ... note - after execution of program the value of i will be 4
The idea is that ++a increments a and returns that value, while a++ returns a's value and then increments a.