Example Execution #1: Contents of labData file Row #1: 3, 8, 11 Changes: 0 Row #
ID: 3857416 • Letter: E
Question
Example Execution #1: Contents of labData file
Row #1: 3, 8, 11 Changes: 0
Row #2: 4, 5, 15 Changes: 6
Row #3: 11, 12, 13 Changes: 2
Row #4: 6, 7, 8 Changes: 9
Row #5: 2, 3, 4 Changes: 14
Row #6: Not possible to change and remain positive.
lab data file
3 8 11
10 5 15
12 13 13
10 12 8
11 8 4
15 19 2
Example Execution #2: Contents of labData file
Row #1: Not possible to change and remain positive.
Row #2: 1, 2, 3 Changes: 0
Row #3: Not possible to change and remain positive.
Row #4: 68, 69, 70 Changes: 33
Row #5: Not possible to change and remain positive.
Row #6: 998, 999, 1000 Changes: 1853
lab data file
7 1 13
1 2 3
2 2 2
90 80 70
-2 -1 0
1350 2500 1000
Example Execution #3: Contents of labData file
Row #1: 99, 100, 101 Changes: 0
Row #2: 83, 84, 85 Changes: 3
Row #3: 1049, 1050, 2000 Changes: 1126
lab data file
99 100 101
85 85 85
2175 1050 2000
Example Execution #4: Contents of labData file
Row #1: 14, 15, 17 Changes: 7
Row #2: 23, 24, 25 Changes: 16
Row #3: 18, 21, 26 Changes: 0
Row #4: 1, 2, 3 Changes: 0
Row #5: Not possible to change and remain positive.
Row #6: Not possible to change and remain positive.
Row #7: 73, 74, 75 Changes: 53
Row #8: 413, 414, 415 Changes: 233
Row #9: 131, 132, 159 Changes: 0
Row #10: 648, 649, 650 Changes: 83
lab data file
21 15 17
30 33 25
18 21 26
1 2 3
1 1 2
1 2 2
110 90 75
510 550 415
131 132 159
700 680 650
MUST BE IN C LANGUAGE
NO ERROR LINE PLEASE
Explanation / Answer
#include <stdio.h>
#include <stdlib.h> // For exit()
int main()
{
FILE *fptr;
char filename[100], c;
printf("Enter the filename to open ");
scanf("%s", filename);
// Open file
fptr = fopen(filename, "r");
if (fptr == NULL)
{
printf("Cannot open file ");
exit(0);
}
// Read contents from file
c = fgetc(fptr);
while (c != EOF)
{
printf ("%c", c);
c = fgetc(fptr);
}
fclose(fptr);
return 0;
}
#include <stdio.h>
#include <stdlib.h> // For exit()
int main()
{
FILE *fptr;
char filename[100], c;
printf("Enter the filename to open ");
scanf("%s", filename);
// Open file
fptr = fopen(filename, "r");
if (fptr == NULL)
{
printf("Cannot open file ");
exit(0);
}
// Read contents from file
c = fgetc(fptr);
while (c != EOF)
{
printf ("%c", c);
c = fgetc(fptr);
}
fclose(fptr);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.