A decreasing sequence of numbers is a sequence of integers where every integer in the sequence is smaller than all other previous integers in that sequence. For example, • 35, 16, 7, 2, 0, -3, -9 is a decreasing sequence of numbers. The length of this sequence is 7 (total numbers in the sequence) and the difference of this sequence is 35 (-9) = 44. • 5 is a decreasing sequence of numbers with length 1 and difference 5-5 = 0 • 99, -99 is a decreasing sequence of numbers with length 2 and difference 99-(-99) = 198 17, 23, 11, 8, -5, -3 is not a decreasing sequence of numbers. Write a program that contains a main() function. The maint function repeatedly asks the user to enter an integer if the previously entered integers form a decreasing sequence of numbers. This process stops as soon as the latest user input breaks the decreasing sequence. Then your function should print the length and difference of the decreasing sequence. Finally, call the main() function such that the call will be executed if and only if the program is run as a stand alone program. Note: your function must not use any data structures like list.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 19PE
icon
Related questions
Question
A decreasing sequence of numbers is a sequence of integers
where every integer in the sequence is smaller than all other
previous integers in that sequence.
For example,
•35, 16, 7, 2, 0, -3, -9 is a decreasing sequence of numbers.
The length of this sequence is 7 (total numbers in the
sequence) and the difference of this sequence is 35 - (-9)
-44.
• 5 is a decreasing sequence of numbers with length 1 and
difference 5-5 = 0
•99,-99 is a decreasing sequence of numbers with length 2
and difference 99-(-99) = 198
•17, 23, 11, 8, -5, -3 is not a decreasing sequence of
%3D
numbers.
Write a program that contains a main() function. The main
function repeatedly asks the user to enter an integer if the
previously entered integers form a decreasing sequence of
numbers. This process stops as soon as the latest user input
breaks the decreasing sequence. Then your function should
print the length and difference of the decreasing sequence.
Finally, call the main() function such that the call will be
executed if and only if the program is run as a stand alone
program.
Note: your function must not use any data structures like list.
Transcribed Image Text:A decreasing sequence of numbers is a sequence of integers where every integer in the sequence is smaller than all other previous integers in that sequence. For example, •35, 16, 7, 2, 0, -3, -9 is a decreasing sequence of numbers. The length of this sequence is 7 (total numbers in the sequence) and the difference of this sequence is 35 - (-9) -44. • 5 is a decreasing sequence of numbers with length 1 and difference 5-5 = 0 •99,-99 is a decreasing sequence of numbers with length 2 and difference 99-(-99) = 198 •17, 23, 11, 8, -5, -3 is not a decreasing sequence of %3D numbers. Write a program that contains a main() function. The main function repeatedly asks the user to enter an integer if the previously entered integers form a decreasing sequence of numbers. This process stops as soon as the latest user input breaks the decreasing sequence. Then your function should print the length and difference of the decreasing sequence. Finally, call the main() function such that the call will be executed if and only if the program is run as a stand alone program. Note: your function must not use any data structures like list.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning