Home > Back-end >  The JAVA language: how to use a for loop to write 2 4 6 8... The value of 98.
The JAVA language: how to use a for loop to write 2 4 6 8... The value of 98.

Time:04-11

The JAVA language: how to use a for loop to write 2 + 4 + 6 + 8 +... The value of the + 98

CodePudding user response:

CodePudding user response:

int sum=0;
for(int i=1; i<50; I++) {
The sum +=I * 2;
}
System. The out. Println (sum);

CodePudding user response:

reference 1/f, green 冘, reply:

. Thank you??

CodePudding user response:

reference qq_45777482 reply: 3/f
Quote: refer to 1st floor green 冘, reply:

. Thank you very much?
you to change the 100 to 98 98

CodePudding user response:

refer to the second floor cyan の. Reply:
int sum=0;
for(int i=1; i<50; I++) {
The sum +=I * 2;
}
System. The out. Println (sum);

. Thank god (* °?=3 °)

CodePudding user response:

green 冘 reference 4 floor, reply:
Quote: refer to the third floor qq_45777482 response:

The
Quote: 1 reference building green 冘, reply:

. Thank you very much?
you to 98 to 100 to 98

Uh huh ╰ '(* ︶ ` *) ╯

CodePudding user response:

Why not just write (int I=2; i<98; I=I + 2)

There is no need to get two + +;

CodePudding user response:

This is certainly not ah...
  • Related