Tuesday, February 18

Sum of Number for given limit in Java.



Hi ALL,

Here I wrote a program for  Sum of Number for given limit in java.

/**
 *
 * @author Balamurgan M
 */
public class method1 {
    public static void main(String arg[]){
        System.out.println(" Sum of Number for given limit ");
        System.out.println(" Sum of 1 to 10 "+sum(1,10));
         System.out.println(" Sum of 1 to 10 "+sum(25,35));
          System.out.println(" Sum of 1 to 10 "+sum(40,50));
       
    }

    private static int sum(int num1,int num2){
        int sum_1=0;     
        for(int i=num1;i<=num2;i++)
            sum_1 +=i;
       return sum_1;
    }
}

No comments:

Post a Comment

Backup files to google drive using PHP coding

 Dear All, To backup files to Google Drive using PHP coding, you can use the Google Drive API and the Google Client Library for PHP. Here...