For each k between 1 and 4, it computes sum as sum+i+j+k; It does it
for each j between 10 and 14; and all of it for every i between 1 and
4. So for example if your sum is 1628 before last step(that should be
for i=4,j=14 and k=4,
your new sum will be 1628+4+14+4=1650
Previous step should be i=4,j=14 and k=3 with sum at start 1607 and at
end 1607+4+14+3=1628
And so on


On May 24, 12:41 pm, SARAN S <[email protected]> wrote:
> Plz Could anyone explain the program, it prints  sum=1650?????
>
> class forloop{
>
>     public static void main(String args[])
>     {
>
>         int sum = 0;
>
>         for(int i=1;i<5;i++){
>
>             for(int j=10;j<15;j++){
>
>                 for(int k=0;k<5;k++){
>
>                     sum+=i+j+k;
>
>                     System.out.println("sum: "+sum);
>
>                             }//k
>                         }//j
>                     }//i
>     }//main
>
> }//forloop class
>
> thanks
> regards
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to