0

What is output of this code and explain me each and every line of code please

int sum=0; for(int i=0;i<4;i++){ if(i℅2==0){ continue; } sum+=i; } System.out.print(sum);

21st May 2017, 5:09 PM
Jayram
Jayram - avatar
5 Antworten
+ 8
What is output of this code and explain me each and every line of code please int sum=0; //initializes sum as 0 for(int i=0;i<4;i++){ //for loop to check for numbers from 0 to 4 if(i℅2==0){ //checks if divisible by 2 continue; //skips iteration of divisible by 2 } sum+=i;//adds number if not divisible by 2 } System.out.print(sum); //print output = 1+3=4
21st May 2017, 5:11 PM
Pixie
Pixie - avatar
+ 6
Please read the comments I have written. It skips the numbers divisible by 2.
21st May 2017, 5:16 PM
Pixie
Pixie - avatar
+ 1
thanks I'd got the answer Sry pixie for distracting u
21st May 2017, 5:58 PM
Jayram
Jayram - avatar
0
how you got 1+3=4
21st May 2017, 5:15 PM
Jayram
Jayram - avatar
0
how u got 1 there I didn't get that please elaborate that 😓😓😓
21st May 2017, 5:20 PM
Jayram
Jayram - avatar