Kizspy | Question: 46
(Choose 1 answer)
Consider the following code snippet that reads and prints the contents of a text file named "data.txt":
#include <stdio.h>
int main() {
FILE *file ptr;
char ch;
file_ptr = fopen("data.txt", "r");
(file_ptr == NULL) { if
printf("Unable to open the file.\n");
return 1;
}
while ((ch = fgetc(file_ptr)) != EOF) { printf("%c", ch);
}
fclose(file_ptr);
return 0;
FUOVER
}
What will be the output of this code when executed, assuming "data.txt" contains the following text:
Hello
This is a sample text file.
A. Hello
This is a sample text file.
B. Hello
C. This is a sample text file.
D. This is a sample text file.Hello