Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Dart program that takes a list of integers and prints the sum of all elements in the list.
- void main() {
- List<int> abc =[2,3,4,5,6];
- print( numsum(abc));
- }
- int numsum(List<int> nums)
- {
- int sum=0;
- for(int i =0;i<nums.length;i++)
- {
- sum = sum+ nums[i];
- }
- return sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement