Write a program such that the sequential input entered by the user is summed or counted, up until the end criteria is seen in the sequence. The end criteria is also defined by the user. No previous information about where the entered sequence is reached to the stop criteria. Both stop criteria and function type is defined by the user inputs in the main function and necessary information is passed to the proper function. As an example, if sum function is chosen with stop criteria 0, and user starts to enter one by one the values 1,2,3,0 in order, the program should stop receiving input immediately whenever the 0 (defined stop criteria) is entered and print out 6 as sum of inputs up to stop criteria. In another case, if -1 is chosen as stop criteria and the count function is chosen by the user, as an example, and the sequence one by one entered is the 3,2,5,1,-1, the program should print 4 to the screen as a number of inputs up to -1 entered. Don’t forget the sequence is entered one by one (1, enter, 2, enter, 3, enter, 0, enter is the sequence of user in the first example)ou will have to define at least 2 functions, one is for sum and the other for count, the function type and stop criteria is chosen in main and depending on the choice the count or sum function is called with necessary value pass. Returned value should be printed in main.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a program such that the sequential input entered by the user is summed or counted, up until the end criteria is seen in the sequence. The end criteria is also defined by the user. No previous information about where the entered sequence is reached to the stop criteria. Both stop criteria and function type is defined by the user inputs in the main function and necessary information is passed to the proper function. As an example, if sum function is chosen with stop criteria 0, and user starts to enter one by one the values 1,2,3,0 in order, the program should stop receiving input immediately whenever the 0 (defined stop criteria) is entered and print out 6 as sum of inputs up to stop criteria. In another case, if -1 is chosen as stop criteria and the count function is chosen by the user, as an example, and the sequence one by one entered is the 3,2,5,1,-1, the program should print 4 to the screen as a number of inputs up to -1 entered. Don’t forget the sequence is entered one by one (1, enter, 2, enter, 3, enter, 0, enter is the sequence of user in the first example)ou will have to define at least 2 functions, one is for sum and the other for count, the function type and stop criteria is chosen in main and depending on the choice the count or sum function is called with necessary value pass. Returned value should be printed in main.

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY