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);
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
+ 6
Please read the comments I have written.
It skips the numbers divisible by 2.
+ 1
thanks I'd got the answer Sry pixie for distracting u
0
how you got 1+3=4
0
how u got 1 there I didn't get that please elaborate that 😓😓😓