Programming in C - UNIT V

13 flashcards · Programming Languages · by Kamala Viswanathan

  1. Which of the following true about FILE *fp? a) FILE is a keyword in C for representing files and fp is a variable of FILE type. b) FILE is a stream c) FILE is a buffered stream d) FILE is a structure and fp is a pointer to the structure of FILE type

    a) FILE is a structure and fp is a pointer to the structure of FILE type

  2. 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 pointer & the second argument is the mode d) None of the mentioned

    (a) A character string containing the name of the file & the second argument is the mode

  3. fseek() should be preferred over rewind() mainly because a) rewind() doesn't work for empty files b) rewind() may fail for large files c) In rewind, there is no way to check if the operations completed successfully d) All of the above

    (c). In rewind, there is no way to check if the operations completed successfully

  4. 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

    (d) It is a type name defined in stdio.h

  5. Which type of files can't be opened using fopen()? a) .txt b) .bin c) .c d) None of the above

    (d) None of the above

  6. If there is any error while opening a file, fopen will return? a) Nothing b) EOF c) NULL d) Depends on compiler

    (c) NULL

  7. It is not possible to combine two or more file opening mode in open () method. a) True b) False c) May be True or False d) Can't Say

    (b) False

  8. What is the purpose of "rb" in fopen() function used below in the code? FILE *fp; fp = fopen("demo.txt", "rb"); a) Open "demo.txt" in binary mode for reading b) Create a new file "demo.txt" for reading and writing c) Open "demo.txt" in binary mode for reading and writing d) None of the above

    (a) Open "demo.txt" in binary mode for reading

  9. In the sequential access method, information in the file is processed ____________ a) one disk after the other, record access doesn't matter b) one record after the other c) one text document after the other d) none of the mentioned

    b) one record after the other

  10. Sequential access method ______ on random access devices. a) works well b) doesnt work well c) maybe works well and doesnt work well d) none of the mentioned

    a) works well

  11. The direct access method is based on a ______ model of a file, as _____ allow random access to any file block. a) magnetic tape, magnetic tapes b) tape, tapes c) disk, disks d) all of the mentioned

    c) disk, disks

  12. For a direct access file ____________ a) there are restrictions on the order of reading and writing b) there are no restrictions on the order of reading and writing c) access is restricted permission wise d) access is not restricted permission wise

    b) there are no restrictions on the order of reading and writing

  13. A relative block number is an index relative to ____________ a) the beginning of the file b) the end of the file c) the last written position in file d) none of the mentioned

    a) the beginning of the file