Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

java problem

Name: Anonymous 2007-05-08 13:00 ID:q5GcBAft

I am not getting this, "i remainder 10 == 0"
--------------------------------------------------

What are the values of i and sum after this code is executed?

    int sum = 0;
    int i = 0;

    for (i=0; i<40; i++)
    {
        if ( i % 10 == 0)
            sum += i;
    }
    System.out.println (“The sum is  “ + sum);

Name: Anonymous 2007-05-08 13:05 ID:q5GcBAft

anyone? ;_;

Name: Anonymous 2007-05-08 13:07 ID:0E4TglNm

I was about to post an infromative reply, but that `anyone?' after five minutes of your original post made me decide otherwise.

Name: Anonymous 2007-05-08 13:08 ID:q5GcBAft

sum is equal to 30

Name: Anonymous 2007-05-08 13:08 ID:Heaven

And this is not a Java problem, either. Modulo operator is used with basically any language.

Name: Anonymous 2007-05-08 13:23 ID:fzWADcEN

You fucking bastard, how dare you question us with this trivial bullshit.

Name: Anonymous 2007-05-08 14:05 ID:DBapDcpW

GET A CLUE FAGSHIT AND DO YOUR OWN HOMEWORK

Name: Anonymous 2007-05-08 15:40 ID:fzWADcEN

>>1
ONE WORD, XML BUILD SYSTEM, JAVA OVER

Name: Anonymous 2007-05-08 17:43 ID:Heaven

>>8
ONE WORD, SHIT THAT WON'T DIE, XML OVER

Name: Anonymous 2007-05-08 18:01 ID:gZIfTdeB

The sum is  60
The i value is 40
Press any key to continue . . .

Name: Anonymous 2007-05-08 18:29 ID:lFFudWqQ

>>1
Are you fucking retarded ? OH I FORGOT THAT'S WHAT WE CALL JAVA PROGRAMMERS. Why don't you run your fucking code and/or do some trivial maths.

Name: Anonymous 2007-05-08 18:39 ID:Jzwx/gR2

NO EXCEPTIONS

Name: Anonymous 2007-05-08 21:08 ID:gZIfTdeB

>>12
throws GetAPieceOfPaperException

Name: Anonymous 2007-05-09 17:33 ID:scsYPEqm

Maybe >>1 is having trouble understanding modulo division?

Your code only sums the integers in the range [0, 40) that are multiples of 10 (that is, all numbers such that if you divide them by 10, their respective remainder is 0, as you wrote with if i%10==0)): 0, 10, 20, and 30. So the sum is 60. After the loop is executed, i == 40 because that's the inverse of your loop's test condition.
If you want sum == 100 after the code is executed, change your loop test to (i <= 40) so i == 40 is part of the sum.

Name: Anonymous 2007-05-09 20:16 ID:bpja0G7B

Sub Paper_()
get.Paper
EndSub

Private Sub Form1_OnLoad()
call Paper
EndSub

Name: Anonymous 2009-03-06 7:35

Condition is something which   YOU SHOULD BE   virtual by default   isolated from each   time interval from.

Name: Anonymous 2009-08-16 22:53

Lain.

Name: Anonymous 2010-12-08 20:24

Name: Sgt.Kabu廯醴kiman掹똆 2012-05-29 1:31

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List