Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

per line. Input should be handled as follows: 1. A nonzero value should be added into a subtotal; 2. A zero value should cause the

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
per line. Input should be handled as follows: 1. A nonzero value should be added into a subtotal; 2. A zero value should cause the subtotal to be printed and reset to zero: 3. Two consecutive zeroes should cause the total (not subtotal) of all the values input to be printed and the program to be terminated. 4. The starter code should display for you on the Replit site. It is provided here at the very bottom of this assignment below the test cases and submission instructions... just in case it is not. 5. Go to the Modules page and click on the "Replit Registration and Use for Students" link to get started. 6. If you have already completed this assignment Test Case 1: 5 6 0 subtotal: 11 3 2 5 0 subtotal: 0 13 13 8 0 subtotal: 8 0 total: 19 Test Case 2: 8 0 subtotal: 8 8 0 subtotal: 8 8 0 subtotal: 8 8 0 subtotal: 8 8 0 subtotal: 8 0 total: 40 Test Case 3: 0 subtotal: 0 \#include // For I/O functions on the keyboard and screen. "/ int main(void) int Total =0; int SubTotal = 0; int Stop=1 int Input; printf ("Enter integers one at a time. A 0 (zero) entered will cause the SubTotal to be printed and reset it to zero Another zero prints a Total and exits the program. (n); while (Stop != ?????) \{ ?????("\%i", \&lnput); / Use the 'Scanf()' function to collect input from the keyboard. Assign it the Input variable you defined above. % Total += ?????; / Immediately add the Input to Total and SubTotal here because you will need it no matter what happens later in the program. * ????? += Input if (Input ==?????){ / Do we have a 0 from the keyboard? % ?????("SubTotal: \%i ", SubTotal); / : Yes! So we print the SubTotal and... % ????? =0; /... reset it to zero % scanf("\%i", ????); " Get another number from the user (you) in order to check for a consecutive zero. "/ if (?????== ????) \& Do we have a second (consecutive) 0 scanf("\%i", ?????); / " Get another number from the user (you) in order to check for a consecutive zero. */ if (?????==?????){ Do we have a second (consecutive) 0 from the keyboard?:" printf("Total: ????? In", Total); / * Yes! So we print the Total and our work is done! * Stop = ?????: Stop the while loop just in case, return 0; F Return 0 quits the current function. \} else 1. Ending curly brace for the end of inner (second) IF statement block. "/ Total += Input; / The consecutive 0 was not entered... % SubTotal += Input; /.... so we increment our totals % ] / Closing curly for the outer (first) IF statement above. % ) 1 Closing curly for the while loop. / 3/ Ending curly for entire function and program.\%/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions