subject

Write a program that outputs the biggest difference (absolute value) between any successive pair of numbers in a list. Such a list might represent daily stock market prices or daily temperatures, so the difference represents the biggest single-day change. The input is the list size, followed by the numbers. If the input is 5 60 63 68 61 59, the output is 7. Hints:
Declare a variable for the current number, and another for the previous number. At the start of each loop iteration, set prevNum
currNum, then get the next number into currNum; Maintain a max difference variable. Initialize it with 0. In each loop iteration, check if the difference between currNum and prevNum exceeds maxDiff, if so, update maxDiff with that difference Don't forget to take the absolute value of the difference before the above comparison Don't try to check the max difference for the first number in the list, since no previous number exists.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 04:30
Eye injuries usually occur as a result of all of the following things, except: a) proper machine operation b) battery explosion c) falling or flying debris d) electric welding arc
Answers: 2
question
Computers and Technology, 23.06.2019 17:00
Companies that implement and apply an information system effectively can create
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
Write a program that prints the day number of the year, given the date in the form month-day-year. for example, if the input is 1-1-2006, the day number is 1; if the input is 12-25-2006, the day number is 359. the program should check for a leap year. a year is a leap year if it is divisible by 4, but not divisible by 100. for example, 1992 and 2008 are divisible by 4, but not by 100. a year that is divisible by 100 is a leap year if it is also divisible by 400. for example, 1600 and 2000 are divisible by 400. however, 1800 is not a leap year because 1800 is not divisible by 400.
Answers: 3
question
Computers and Technology, 24.06.2019 02:20
The first time a user launches the powerpoint program, which view is shown allowing the user to access recent presentations or create new presentations based on templates?
Answers: 1
You know the right answer?
Write a program that outputs the biggest difference (absolute value) between any successive pair of...
Questions
question
Mathematics, 13.03.2021 01:10
question
Mathematics, 13.03.2021 01:10
question
Mathematics, 13.03.2021 01:10
question
Chemistry, 13.03.2021 01:10
question
Mathematics, 13.03.2021 01:10
question
Spanish, 13.03.2021 01:10
Questions on the website: 13722363