Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 6 subjective questions File Handling

CAP1008 — C Programming 20 questions with model answers. Write yours first, then compare.

Read the notes Practice MCQs
  1. Question 1 of 20

    Define a file in the context of C programming. Explain why file handling is important in real-world applications.

  2. Question 2 of 20

    Describe the different categories of files used in C programming.

  3. Question 3 of 20

    Distinguish between text files and binary files in C with suitable examples.

  4. Question 4 of 20

    Explain the process of opening a file in C using the fopen() function. Describe its syntax and return value.

  5. Question 5 of 20

    List and explain the various file opening modes available in C.

  6. Question 6 of 20

    Explain the importance of closing a file in C. Describe the fclose() function with syntax and example.

  7. Question 7 of 20

    Describe the character input/output functions getc()/fgetc() and putc()/fputc() with examples.

  8. Question 8 of 20

    Explain the string handling functions fgets() and fputs() used in file operations with syntax and examples.

  9. Question 9 of 20

    Explain the formatted I/O functions fprintf() and fscanf() with syntax and a suitable example program.

  10. Question 10 of 20

    Explain the block I/O functions fread() and fwrite() used for reading and writing binary files. Illustrate with an example.

  11. Question 11 of 20

    Compare sequential file access and random file access in C. Explain the role of fseek(), ftell(), and rewind().

  12. Question 12 of 20

    Write a C program to read the contents of a text file and display it on the screen. Explain the logic used.

  13. Question 13 of 20

    Explain the concept of the End-of-File (EOF) marker and the feof() function in C file handling.

  14. Question 14 of 20

    Write a C program to copy the contents of one file into another file. Explain each step.

  15. Question 15 of 20

    What is a file pointer in C? Explain the role of the FILE structure in file handling.

  16. Question 16 of 20

    Explain how to perform reading and writing of structures into a binary file in C with a complete example program.

  17. Question 17 of 20

    Describe the complete file handling process in C, from opening to closing a file, covering all essential steps. Support your answer with a general program structure.

  18. Question 18 of 20

    Distinguish between the file functions fprintf()/fscanf() and fwrite()/fread(). When should each pair be used?

  19. Question 19 of 20

    Explain error handling in file operations in C. Discuss the use of ferror(), perror(), and checking return values.

  20. Question 20 of 20

    Write a C program to count the number of characters, words, and lines in a text file. Explain the logic.

That's unit 6

Long answers stick best when they're tested again soon. Run the MCQs on this unit, then come back to the questions you found hardest.