Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use C language But NO Array Use Only Ttdio.h Seems hard for me .I can write with array but can't write without array. Write a

Use C language

But NO Array

Use Only Ttdio.h

Seems hard for me .I can write with array but can't write without array.

Write a program that reads in a series of lines of input character by character (using 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 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 three digits before the decimal point, and up to three 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.125

20.25

0.875

921.50

31

The required output is:

Each of the input floating point values, printed on a separate line with three 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 3 digits of precision. For example, the total of the sample input given above is 976.750, so the required output for this input would be:

3.125

20.250

0.875

921.500

31.000

Total: 976.750

Be sure to include a descriptive message for the user to input the values correctly. You can assume that the user will follow your directions (which should be consistent with the description above), so no exception handling for incorrect input is required. You cannot change the input specifications given above, however.

CONSTRAINTS:

You are not allowed to use arrays on this portion of the lab assignment.

You must use getchar() to read in the floating point values one character at a time (i.e. DO NOT USE scanf()).

-Only use printf() to output the floating point numbers and the total (Do not useputchar()).

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