Question
Write a C program such that the sequential input entered by the user is summed or counted, up until the end criteria is seen in
Write a C 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. Dont 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).
***to make it more clear, you 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started