double myData[16] = { 0 }; int i = 0; FILE *fp; fp = fopen(\"c:\\\\data\\\\file2
ID: 3930874 • Letter: D
Question
double myData[16] = { 0 };
int i = 0;
FILE *fp;
fp = fopen("c:\data\file2.txt", "r");
if (fp != NULL)
{
double val;
while (fscanf(fp, "%lf", &val) == 1)
{
myData[i] = val; i++;
fclose(fp);
}
If the data file contains between 5 and 16 values, which one of the following statements is FALSE?
a. Any array elements that are not populated inside the while loop will contain the value 0.
b. The value of variable i will contain the number of values successfully stored into the array.
c. The next call to fscanf, after reading the last value from the file, will return a value other than 1.
d. Nothing will be stored by the while loop into any element of the array
Explanation / Answer
The statement D is false. The while loop will store all the values in the file to the array. The while loop condition will hold until all the values in the file are read.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.