0
Friends i want know how the output is come 6
public class Program { public static void main(String[] args) { int m,n=0; for(m=1; m<=4; m++){ n+=m; n--; } System.out.println(n); } } /* Output 6 */ Please understand me briefly...
4 ответов
+ 5
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥
Not sure I understand
https://code.sololearn.com/cleVb0ajs7Uz/?ref=app
+ 3
Normally 1+2+3+4 but in each of 4 loops n--
So 10 -4=6
+ 1
(n+m)-1=n (equal to).
0+1 -1 =0
0+2 -1 =1
1+3 -1 =3
3+4 -1 =6
@Kiibo since n-- is a separate statement. (post or pre, no difference, not effect in result.)
@Oma Falk teacher is fast, applied farmula some of sequestial numbers - iterations just.