Advertisement
chiplu

Java sum using array

Nov 17th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.35 KB | None | 0 0
  1. package dadaproject.company;
  2. import java.util.Scanner;
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.     int a[]={4,6,7,3,9,10,44,55,12};
  8.     sum(a);
  9.  
  10.     }
  11.     public static void sum(int []a)
  12.     {
  13.         int sum =0;
  14.         for(int i:a)
  15.         {
  16.             sum = sum+i;
  17.         }
  18.         System.out.print(sum);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement