The break statement of the C language interrupts (breaks) a loop, giving control
ID: 3775084 • Letter: T
Question
The break statement of the C language interrupts (breaks) a loop, giving control to the first statement that follows after the current loop statement.
Function readVector() defined below reads up to *pn int numbers into an array a from a FILE* f already open and returns in *pn the number of elements read from f:
void readVector(FILE* f, int a[], int *pn) {
int i;
for (i=0; i<*pn; i++) {
if (fscanf(f, “%d”, &a[i]) != 1) {
break;
}
}
___________
}
What is the correct statement that should replace the blank line ?
*pn = i;
return i;
return *pn;
pn = i;
*pn = i;
return i;
return *pn;
pn = i;
Explanation / Answer
Option A is the right answer as the value i should be assigned to a pointer variable not as its address.
Where i is the no of integers countfrom file.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.