Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the code to extend 5. Problem E getchar, floating point literals, arrays (40 pts) Specification Extend the program in D, so that it

image text in transcribed

This is the code to extend

image text in transcribed

image text in transcribed

5. Problem E getchar, floating point literals, arrays (40 pts) Specification Extend the program in D, so that it uses getchaz (only) to read and interpret floating point literals. Implementation Name your program lab2E.c. The program: should use getchar() to read inputs (from standard in) until EOF is read. The input contains floating point literals and integer literals separated by one blanks or new line characters. The program interprets each literal and put into an float array. When wend of 6 file" is reached, the program prints out the value of each float as well as the value multiplied by 2, as shown in sample output below. assume all floating point literals are valid float/double or int literals (both 2.3, 5, .4 are considered valid). There are no negative numbers. should not use other input 10 functions such as scanf(), fgets(). Only getChar() is allowed to read input. (So have to read char by char.) should not use other library function such as atoil), atol), atof(), strtol(), strtoull). (So have to convert manually) should not use extra array. Only use one array resul)- Sample Inputs/Outputs: (download - don't copy/paste - the input file input22. Ext) red 306 a.gce lab2.c -o lab2E red 306 lab2E 2.3 4.56 43.3 43 5.3 .3 1.2 AD 2.3000 4.6000 4.5600 9.1200 43.3000 86.6000 43.0000 86.0000 5.3000 10.6000 0.3000 0.6000 1200 24 #include #define SIZE 100 int main() { int c; int value; int resu[SIZE]; int negative; int index 0; int i; value = 0; c = getchar(); while (c != EOF) { if (c == '-'){ negative } 1; else if (c == || C == ' ') TUT { if(negative 1) { c = getchar(); while ( c != EOF) { if (c == '-'){ negative = 1; } else if (c == Il c == ' ' ) { if(negative == 1) { value = -value; } resu[index] = value; index++; value = 0; negative = 0; ific if (c >= 'O' && c

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

Question

=+j Describe the various support services delivered by IHR.

Answered: 1 week ago

Question

=+j Explain IHRMs role in global HR research.

Answered: 1 week ago