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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education