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.
Write a
Step by step
Solved in 2 steps with 2 images