Even numbers

  • 2
  • Locked
A for loop simplifies the counting, simplifies displaying text, and simplifies... the life of a programmer! And it saves a lot of time: just a couple of simple lines of code and you can display every even number from 1 to 100 inclusive. Let's try it, but be sure to put each value on a separate line.
You can't complete this task, because you're not signed in.
Comments (14)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
ImDevin
Level 15 , Old Town, United States
2 April 2021, 01:55
is no one doing these tasks? no comment since May 20th 2020. I think I might keep posting these comments and see if anyone else writes anything :)
bob
Level 8 , Milan, Italy
21 May 2020, 01:30
for anyone who thinks that the seemingly particular word choice of "inclusive" would imply that we are to practice our "following particular details" duty and include 1 and 100, think again. they only want the even numbers 2 to 100. See, your code was fine!
raulGLD
Level 8 , Cluj-Napoca, Romania
19 October 2020, 09:15
God damn! I was looking fo this. Thank you! The word "inclusive" made me think the same way, so I added 1 and then all the even numbers.. this should really be changed. So for any new comers, just make sure you write all the even numbers from 1 to 100, WITHOUT 1 itself.
Paul Harman
Level 5
21 April 2020, 03:14
System.out.println("1"); for (int i = 2; i <= 100; i = i +2){ System.out.println(i);
Paul Harman
Level 5
21 April 2020, 03:13
I have 1 listed and then even numbers between 2 and 100 inclusive listed on screen but cannot satisfy third criteria.
Paul Harman
Level 5
21 April 2020, 03:14
System.out.println("1"); for (int i = 2; i <= 100; i = i +2){ System.out.println(i);
Paul Harman
Level 5
21 April 2020, 03:23
removed the line to print 1, task is misleading in some will assume we are being asked to print 1 even though not even
Scott Böning
Level 14 , Deggendorf, Germany
12 February 2020, 17:58
If you don't get output: you don't need to check whether the number is even. 1 isn't an even number, so it doesn't have to be displayed. The first number to be displayed is 2. So you just have to increment by two.
IO.Error
Level 24 , Bremen, Germany
11 January 2020, 22:47
unable to get output
Glenn Meyer
Level 8 , Cleveland, United States
29 October 2019, 01:52
Not sure why this is rated so low... did you guys skip the Pascal example page? :D This is a pretty straightforward for loop.
18 September 2019, 16:17
This seems to be a common issue. I am not getting any output too.
Laurence Chadwell
Level 7 , San Antonio, United States
1 September 2019, 01:38
I solved this one, but the output window was not visible. @Roman
Valeri Burlacu
Level 15 , Bamberg, Germany
5 July 2019, 15:58
I don't understand... what is the problem ? O_O