Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Q19 Sum array elements
- import java.util.*;
- public class Main
- {
- public static void main(String[] args) {
- int[] arr ={1,2,3,4,5};
- int sum = 0;
- System.out.println("Sum of array elements is ");
- for(int n : arr){
- sum+=n;
- }
- System.out.print(sum);
- }
- }
- /*
- Enter the number
- Sum of array elements is
- 15
- */
Add Comment
Please, Sign In to add comment