You are viewing a single comment's thread. Return to all comments →
You can even do this without taking an array:
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int sum=0; int n=sc.nextInt(); for(int i=0;i<n;i++) { sum = sum+(sc.nextInt()); } System.out.println(sum); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Simple Array Sum
You are viewing a single comment's thread. Return to all comments →
You can even do this without taking an array: