Question: 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

 This is the code to extend 5. Problem E getchar, floating

This is the code to extend

point literals, arrays (40 pts) Specification Extend the program in D, so

that it uses getchaz (only) to read and interpret floating point literals.

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!