On May 24, 5: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;
In the loops, sum is compounded by values in i, j and k. A hundred
loops later, sum is 1650. Such as:
// A short hand.
sum += i + j + k;
// Same as:
sum = 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