+ 1
int i= 1;. for( ; i<=10; i = i++)
If we initialize the i in the declaration before the (for statement ) . Why we use semicolon in the initialize place in the for statement ?
3 RĂ©ponses
+ 2
The semicolon is where it always is, just without another assignment. The syntax of the for loop doesn't change just due to another assignment.
+ 1
its for loop syntax
for(initial value; expression ; ++/--)
The compiler see after first semicolon as expression, so there shd be two semicolons as it basic syntax.
+ 1
int a = 2;
int b = a++;
Here value of b is 2 and not 3
So, similarly
int a = 2;
a = a++;
a has not increased!
Instead you can try a++ or ++a or a = ++a all these methods will increment a