id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > da2022_11_07_sumFirstLast
prev  |  next  |  chance

Write a method that returns the sum of the first and last elements in an array. As a precondition, you may assume that 'nums' will contain at least 2 elements.


da2022_11_07_sumFirstLast([4, 2434, 64, 7, 3235, 1]) → 5
da2022_11_07_sumFirstLast([1, 2, 3, 4, 5, 6, 7]) → 8
da2022_11_07_sumFirstLast([-40, 35, 894, 4539, 241, 40]) → 0

...Save, Compile, Run (ctrl-enter)

public int da2022_11_07_sumFirstLast(int[] nums) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 220

Copyright Nick Parlante 2017 - privacy