C Programming – File Access

C Programming - File Access

Question 1
 The first and second arguments of fopen are
A
A character string containing the name of the file & the second argument is the mode.
B
A character string containing the name of the user & the second argument is the mode.
C
A character string containing file poniter & the second argument is the mode.
D
None of the mentioned of the mentioned
Question 2
For binary files, a ___ must be appended to the mode string.
A
Nothing
B
“b”
C
“binary”
D
“01″
Question 3
 If there is any error while opening a file, fopen will return
A
Nothing
B
EOF
C
NULL
D
Depends on compiler
Question 4
Which is true about getc.getc returns?
A
The next character from the stream referred to by file pointer
B
EOF for end of file or error
C
Both a & b
D
Nothing.
Question 5
When a C program is started, O.S environment is responsible for opening file and providing     pointer for that file?
A
Standard input
B
Standard output
C
Standard error
D
All of the menitoned
Question 6
 FILE is of type ______ ?
A
int type
B
char * type
C
struct type
D
None of the mentioned
Question 7
What is the meant by ‘a’ in the following operation?     fp = fopen(“Random.txt”, “a”);
A
Attach
B
Append
C
Apprehend
D
Add
Question 8
Which of the following mode argument is used to truncate?
A
a
B
f
C
w
D
t
Question 9
Which type of files can’t be opened using fopen()?
A
.txt
B
.bin
C
.c
D
None of the mentioned
Question 10
 Which of the following fopen statements are illegal?
A
fp = fopen(“abc.txt”, “r”);
B
fp = fopen(“/home/user1/abc.txt”, “w”);
C
fp = fopen(“abc”, “w”);
D
None of the mentioned
Question 11
 What does the following segment of code do?     fprintf(fp, “Copying!”);
A
It writes “Copying!” into the file pointed by fp
B
It reads “Copying!” from the file and prints on display
C
It writes as well as reads “Copying!” to and from the file and prints it
D
None of the mentioned
Question 12
FILE reserved word is
A
A structure tag declared in stdio.h
B
One of the basic datatypes in c
C
Pointer to the structure defined in stdio.h
D
It is a type name defined in stdio.h
Question 13
. What is the output of this C code?
    #include 
    int main()
    {
    FILE *fp = stdin;
    int n;
    fprintf(fp, "%d", 45);
    }
A
Compilation error
B
45
C
Nothing
D
Depends on the standard
Question 14
What is the output of this C code?
    #include 
    #include 
    int main()
    {
    FILE *fp = stdout;
    int n;
    fprintf(fp, "%d", 45);
    }
A
Compilation error
B
45
C
Nothing
D
Depends on the standard
Question 15
 stdout, stdin and stderr are
A
File pointers
B
File desciptors
C
Streams
D
Structure
Question 16
 Which of the following statements about stdout and stderr are true?
A
Same
B
Both connected to screen always.
C
Both connected to screen by default.
D
stdout is line buffered but stderr is unbuffered.
Question 17
What is the output of this C code?
    #include 
    int main()
    {
    FILE *fp = stdout;
    int n;
    fprintf(fp, "%d ", 45);
    fprintf(stderr, "%d ", 65);
    return 0;
    }
A
45 65
B
65 45
C
65
D
Compilation error
Question 18
What is the output of this C code?
    #include 
    int main()
    {
    FILE *fp = stdout;
    int n;
    fprintf(fp, "%d\n ", 45);
    fprintf(stderr, "%d ", 65);
    return 0;
    }
A
45 65
B
65 45
C
65
D
Compilation error
Question 19
What is the output of this C code?
    #include 
    int main()
    {
    FILE *fp = stdout;
    int n;
    fprintf(fp, "%d ", 45);
    fflush(stdout);
    fprintf(stderr, "%d", 65);
    return 0;
    }
A
45 65
B
65 45
C
45
D
Compilation error


Check Your Answers:

  1. A
  2. B
  3. C
  4. C
  5. D
  6. C
  7. B
  8. C
  9. D
10. D
11. A
12. D
13. C
14. B
15. A
16. C
17. B
18. A
19. A















SHARE

Unknown

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment