367,686 views
36 votes
36 votes
Explain float data [100]​

Explain float data [100]​-example-1
User Pavnish Yadav
by
2.9k points

1 Answer

7 votes
7 votes

Answer:

useless

Step-by-step explanation:

float data[100] allocates an array of 100 floats on the stack. In the attached program however, these values are never used. A sum is accumulated on the fly, so there is no need to store the individual values for later use, as there is no later use.

In fact, if the number entered for setSize exceeds 99, the program will even corrupt memory, as you will write beyond the allocated size for the array.

User Finer Recliner
by
2.8k points