Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LAB DESCRIPTION PART 1. (50%). Mandatory file name: lab1p1.c Write a program that reads in a series of lines of input character by character (using

LAB DESCRIPTION PART 1. (50%). Mandatory file name: lab1p1.c Write a program that reads in a series of lines of input character by character (using the library function getchar()). The first line of the input contains an integer which specifies the number of remaining lines of input, each of which contains a floating point number. The integer value on the first line can be read with (the library function) scanf(), but all of the following lines can only be read with getchar(). Each line, after the first, contains a single floating point value, with up to four digits before the decimal point, and up to four digits following the decimal point, but there is not necessarily a decimal point in each number; i.e., it may appear to be an integer, but the digits should be read by your program, and the number should be converted to a corresponding floating point number. For instance, suppose the following input: 5 3.1255 20.25 0.875 1921.50 31 The required output is: Each of the input floating point values, printed on a separate line with four digits of precision, using printf(); On the last line of the output, the string Total: followed by the sum of the input values, printed with printf() to 4 digits of precision. For example, the total of the sample input given above is 1976.7505, so the required output for this input would be: 3.1255 20.2500 0.8750 1921.5000 31.0000 Total: 1976.7505 Do not concern yourself with small differences in the total due to rounding, as the grader will not deduct points for this.

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_2

Step: 3

blur-text-image_3

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