Print the following java. Enter 5 random numbers. Add the adjacent number. The adjacent numbers in the result should be added. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Print the following java. Enter 5 random numbers. Add the adjacent number. The adjacent numbers in the result should be added.

ex 1 2 3 4 5 6(add adjacent) 3 5 7 9 (add adjacent) 8 12 16 (add adjacent) 20 28 (add adjacent) 48

5th Aug 2017, 10:14 AM
Gaurav Kumar Dhangar
Gaurav Kumar Dhangar - avatar
2 Answers
+ 2
We can use array
5th Aug 2017, 12:48 PM
Saumya
Saumya - avatar
0
@Saumya I used scanner to input the 5 numbers then I used two for loops but after second line of output, the ans is different
20th Aug 2017, 9:59 AM
Gaurav Kumar Dhangar
Gaurav Kumar Dhangar - avatar