Java Even Number Loop (JENL)

Mission bro, sorry I want to ask. I'm stuck in the for loop part bro. How do I get the values ​​from the largest to the smallest to appear? Thank you very much for your enlightenment bro.

Answer

Just try making it like this, bro.

for (i=batas; i>=2; i--){
if(i%2 == 0){
     cetaki; //dengan instruksi sebenarnya
    }
    else{
     cetak spasi ""; //dengan instruksi sebenarnya
    }
}

The actual meaning of the instructions in the comment above is to use "printout gan" I'm just too lazy to type it for that hahaha please adjust it.

It wants to display even values ​​from the largest to the smallest, right bro?

Okay, so all you have to do is reverse the parameters in the loop.

What do you mean bro, I still don't understand -- auditorinside

So,

i=batas; i>=2; i-2

Later, once you have tried it, please provide a capture of what the output looks like, just to know whether the results are as expected or close to expectations.

Wait... I think your parameters above are still wrong, because to find an even value does not mean adding 2 (i+2) to everything, nor subtracting 2. But the correct one is x where x modulus 2 = 0.

gosh, I'm getting more dizzy, bro, so what should I do, bro? -- auditorinside

Bro, after trying it, it worked quite well, but why is there a zero after the comma?

That's because you use the "float" data type bro for the limit variable. Please change it to "int" bro first so that it becomes an integer value.

Okay, great, thanks bro!!!!!! successfull!!!


Post a Comment

Previous Next

نموذج الاتصال