Join Today
Results 1 to 2 of 2

Thread: A simple java program sum of n number

          
   
   
  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    20

    A simple java program sum of n number

    Hey guy i am in big problem.Actually i don't having much knowledge about Java.I am familiar only with Java.I don't have much knowledge about programing.So guys help me in writing a program on to above topic "A simple Java programing sum of n number using class,object and methods."

  2. #2
    Junior Member
    Join Date
    Aug 2011
    Posts
    18

    Re: A simple java program sum of n number

    i hope this will help u
    ****** Java Program To Print Sum Of 'n' Number ******/

    class Add
    {
    public static void main (String args[])
    {
    int n = 15;
    int sum = 0;
    for(int i = n;i>=0;i--)
    sum = sum + i;
    System.out.println("Sum = "+ sum);
    }
    }

    /*************** OUTPUT *************
    * *
    * Sum = 120 */


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •