+ 1

++a,a++,--a,a-- means

int a=6; b=++a console.writeline(b) ans plzz and why

1st Mar 2017, 12:29 PM
Suresh
Suresh - avatar
3 Réponses
+ 2
a++ get (a) value before increment a. ++a get (a+1) before increment a. In both, the result of a=a+1. Example a = 6; Print(a++) output 6, and Print(++a) output 7. After a = 7
1st Mar 2017, 12:58 PM
Luis Fabricio Tano
Luis Fabricio Tano - avatar
+ 1
++a means pre increment, here the value of a is increment by 1. a++ means post increment, here the value of a=a+1. same thing happen with --a,a--
1st Mar 2017, 2:52 PM
Mayank Gupta
Mayank Gupta - avatar
0
b = a++ //6 will become value before incrementation b = ++a //7 becomes value after incrementation Same goes for a-- and --a b = a-- //6 b = --a //5
1st Mar 2017, 1:49 PM
Andre Littiere
Andre Littiere - avatar